开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第19天,点击查看活动详情
tsconfig.js文件的配置的说明
/* Projects */
"incremental": true
TS编译器再第一编译后生成一个存储编译信息的文件,第二次编译会在第一次的基础上进行编译,可以提升编译速度
"composite": true
启用允许TS项目与项目引用一起使用的约束
"tsBuildInfoFile": "./",
增量编译文件的存储位置
"disableSourceOfProjectReferenceRedirect": true,
在引用组合项目时,禁用首选源文件而不是声明文件
"disableSolutionSearching": true,
编辑时从多个项目引用检查中选择一个项目
"disableReferencedProjectLoad": true,
/* Language and Environment */
"target": "es2016",
Ts需要引用的库,即文件声明,es5默认引入dom,es5,sccripthost,如需要使用es的高级版本特性,
"lib": [],
同城需要配置,如es的数组的新特性需要引入“es2019.Array”
"jsx": "preserve",
按这个生成jsx
"experimentalDecorators": true,
启用时TC39第二阶段草稿装饰实验支持
"emitDecoratorMetadata": true,
为源文件中的修饰声明发出设计类型数据
"jsxFactory": "",
制定针对jsx emit 使用的jsx工厂函数,例如“react” createElement或者h "jsxFragmentFactory": "",
制定针对jsx emit时用于片段的jsx片段引用
"jsxImportSource": "",
指定使用jsx react jsx 时用于导入jsx工厂函数的模块说明符
"reactNamespace": "",
指定为createElement调用的对象,这仅适用于针对reactjsx emit情况
"noLib": true,
禁止使用包含任何库文件,包含默认库 d ts
// "useDefineForClassFields": true,
发出符合EcmaScript标准的类字段
/* Modules */
"module": "commonjs",
生成代码的模版标准,可以选es模式 amd 和umd
"rootDir": "./src",
制定输出文件目录,用于控制目录结构
// "moduleResolution": "node",
模块解析策略,ts默认用node的解析策略,即对应的方式导入
// "baseUrl": "./",
解析飞相对的模块地址,默认是当前目录
// "paths": {},
路径映射相对于baseURl
// "rootDirs": [],
将多个目录放在虚拟目录下,用于运行时,即编译后引入文件的位置可能发生改变,这也设置可以虚拟src和out在同一个目录下,不用区改变路径也不会报错
// "typeRoots": [],
声明文件目录,默认是node_modules/@types
// "types": [],
加载的声明文件包
// "allowUmdGlobalAccess": true,
允许在模块中全局变量的方式范围umd模块
// "resolveJsonModule": true,
启用导出json文件
// "noResolve": true,
不允许 import require 或 reference 扩展 typescript应添加到项目中的文件数
/* JavaScript Support */
// "allowJs": true,
允许编译器编译js jsx文件
// "checkJs": true,
允许在js文件中报错,通常与allowjS一起使用
// "maxNodeModuleJsDepth": 1,
制定用于 检查 “node modules” 中javascript 文件的最大深度,仅使用于 allowjs
/* Emit */
// "declaration": true,
生成声明文件,开启后自动生成声明文件
// "declarationMap": true,
为声明文件生成sourceMap
// "emitDeclarationOnly": true,
只生成声明文件,而不会生成js文件
// "sourceMap": true,
生成目标文件的sourceMap文件
// "outFile": "./",
将多个项相互依赖的文件生成一个文件,可以在AMd模块中,即开启时应设置 module : AMD
"outDir": "./dist",
制定输出目录
// "removeComments": true,
删除主食
// "noEmit": true,
不输出文件,
// "importHelpers": true,
通过tslib引入helper函数,文件必须是模块
// "importsNotUsedAsValues": "remove",
为仅用于类型的导入制定发射检查行为
// "downlevelIteration": true,
为迭代发出更符合要求,但冗长且性能差的javascript
// "sourceRoot": "",
指定调试器查找参考源代码根路径
// "mapRoot": "",
指定调试器应该定位映射文件位置,而不是生成位置
// "inlineSourceMap": true,
生成文件的 inline sourcemap iilinesourcemap 会包含在js文件中
// "inlineSources": true,
在发出的js内包含源代码
// "emitBOM": true,
// "newLine": "crlf",
// "stripInternal": true,
// "noEmitHelpers": true,
// "noEmitOnError": true,
如果报告了任何检查类型错误,则禁止发送文件
// "preserveConstEnums": true,
禁用删除生成代码中的const enum
// "declarationDir": "./",
制定生称声明文件
// "preserveValueImports": true,
在js输出中保留未使用导入值,否则会被删除
/* Interop Constraints */
// "isolatedModules": true,
// "allowSyntheticDefaultImports": true,
"esModuleInterop": true,
// "preserveSymlinks": true,
"forceConsistentCasingInFileNames": true,
/* Type Checking */
// "strict": true,
严格模式
// "noImplicitAny": true,
// "strictNullChecks": true,
// "strictFunctionTypes": true,
// "strictBindCallApply": true,
// "strictPropertyInitialization": true,
// "noImplicitThis": true,
// "useUnknownInCatchVariables": true,
// "alwaysStrict": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
// "exactOptionalPropertyTypes": true,
// "noImplicitReturns": true,
// "noFallthroughCasesInSwitch": true,
// "noUncheckedIndexedAccess": true,
// "noImplicitOverride": true,
// "noPropertyAccessFromIndexSignature": true,
// "allowUnusedLabels": true,
// "allowUnreachableCode": true,
/* Completeness */
// "skipDefaultLibCheck": true,
"skipLibCheck": true