Cocos Creator TS Compile Check SOP
Mandatory TypeScript compile check before committing code to a Cocos Creator 3.x project.
Command
npx tsc --noEmit
Must pass with zero errors before any commit.
Common Errors & Fixes
| Error | Fix |
|---|---|
Cannot find module 'cc' |
Add @cocos/creator-types to tsconfig |
Property 'xxx' does not exist |
Check Cocos API version compatibility |
Type 'X' is not assignable |
Check Cocos 3.x type differences from 2.x |
tsconfig.json Checklist
-
compilerOptions.target:"ES2015"or higher -
compilerOptions.module:"commonjs"or"ES2015" -
compilerOptions.strict:truerecommended -
compilerOptions.skipLibCheck:truefor faster checks -
include: covers allassets/**/*.ts
See references/tsconfig-template.md for a complete working tsconfig.json.