Skip to content

tsconfig详解

输出

参数说明类型默认值可选值
noEmit无输出booleanfalse-
target输出的JavaScript文件的ES版本stringes6es2015/es2016/...
outDir输出目录string--
removeComments是否清除注释booleanfalse-
sourceMap是否生成sourceMap文件booleanfalse-
declaration是否生成声明文件booleanfalse-
declarationDir生成声明文件的目录string--
declarationMap生成声明文件的sourceMapbooleanfalse-
module生成的模块格式stringcommonjsnone/commonjs/amd/system/umd/es6

开发与编译

参数说明类型默认值可选值
lib编译过程中需要的库列表string[]-
moduleResolution模块解析器stringnodeclassic/node
allowJs是否允许编译js代码booleanfalse-

严谨性与健壮性

参数说明类型默认值可选值
strict是否开启严格模式booleanfalse-
noImplicitAny存在隐式any时报错booleanfalse-
noImplicitThis存在隐式this时报错booleanfalse-
strictNullChecks严格性的null值检查(例如不能给number类型的变量赋null值)booleantrue-
noUnusedLocals不允许声明变量但无使用booleanfalse-
noUnusedParameters不允许声明函数参数但不使用booleanfalse-
allowUnreachableCode允许无法达到的代码booleantrue-
strictBindCallApply调用bind/call/apply方法时,必须符合函数的参数booleantrue-