tsconfig.json
Therefore, some options need to configured carefully to make the IDE’s inspection function consistent with the compilation behavior in Cocos Creator.
The following options should not be modified explicitly:
For example, if tsconfig.json
is set to:
However, the implied in Creator is es2015
, therefore it may prompt errors such as “require undefined” at runtime.
The following script code is legal for Creator, but the IDE may report an error. This is because compilerOptions.target
is set to es5
, while Set
was introduced in ES6.
It is also possible to freely modify options.
Set compilerOptions.noImplicitAny
to true
in tsconfig.json
, as using an IDE (such as Visual Studio Code), the corresponding error prompt will be received.
For most projects, some options in are fixed. For example, compilerOptions.target
, compilerOptions.module
and Cocos Creator type declarations, file location, etc.
Due to the good design of tsc
, the extends
option allows tsconfig.json
to be cascadable. Cocos Creator supports this, therefore, the fixed tsconfig
option is placed under {project path}/tmp/tsconfig.cocos.json
and managed by Cocos Creator.
Fortunately, Creator will automatically generate such a file when creating a new project.