Compiler Options
一级属性 Top Level
files,extends,include,exclude andreferences
compilerOptions
类型检查 Type Checking
allowUnreachableCode, 默认值: false 不报告执行不到的代码错误 (不建议修改此选项)
allowUnusedLabels, 默认值: false 不报告未使用的标签错误
alwaysStrict, 默认值: false 以严格模式解析并为每个源文件生成 “use strict”语句
exactOptionalPropertyTypes
noFallthroughCasesInSwitch, 默认值: false 报告 switch 语句的 fallthrough 错误。(即,不允许 switch 的 case 语句贯穿)noImplicitAny, 默认值: false(strict 会开启) 是否可以使用 any 类型
noImplicitOverride,
noImplicitReturns,noImplicitThis,默认值: false(strict 会开启) 当 this 表达式的值为 any 类型的时候,生成一个错误
noPropertyAccessFromIndexSignature,
noUncheckedIndexedAccess,
noUnusedLocals,默认值: false 报告未使用的本地错误
noUnusedParameters,strict,默认值: false 开启相当于开启所有 strict 选项和 noImplicitAny、noImplicitThis
strictBindCallApply,
strictFunctionTypes,对函数类型启用严格检查
strictNullChecks,启用严格的 NULL 检查
strictPropertyInitialization
useUnknownInCatchVariables
模块 Modules
allowUmdGlobalAccess,baseUrl,一般为’.’module,默认值 target === ‘ES6’ ? ‘ES6’ : ‘commonjs’, 可选 commonjs,amd,umd,system,esnext,node12,nodenext。一般为lib为commonjs,es为esnext
moduleResolution,可选’classic’、’node’ 一般为’node’
noResolve,paths,基于 baseUrl 的路径映射的列表resolveJsonModule,默认值: false 模块导入 import 可以导入 .json 文件
rootDir,
rootDirs,
typeRootstypes,Array
输出 Emit
declaration,默认值: false 构建 ts 文件时 生成相应的 .d.ts 文件
declarationDir,
declarationMap,
downlevelIteration,
emitBOM,
emitDeclarationOnly,importHelpers, 默认值: false import 提示,建议打开
importsNotUsedAsValues,
inlineSourceMap,
inlineSources,
mapRoot,
newLine,noEmit,默认值: false 不生成输出文件
noEmitHelpers,
noEmitOnError,outDir,编译目录
outFile,
preserveConstEnums,
preserveValueImports,
removeComments, 默认值: false 是否删除注释
sourceMap,默认值: false 生成相应的 .map 文件。
sourceRoot,
stripInternal
JavaScript Support
allowJs,允许 js
checkJs,检查 js
maxNodeModuleJsDepth
Editor Support
disableSizeLimit andplugins
Interop Constraints
allowSyntheticDefaultImports,esModuleInterop,开启后默认开启 allowSyntheticDefaultImports,建议开启
forceConsistentCasingInFileNames,
isolatedModules
preserveSymlinks
Backwards Compatibility
charset,
keyofStringsOnly,
noImplicitUseStrict,
noStrictGenericChecks,
out,
suppressExcessPropertyErrors
suppressImplicitAnyIndexErrors
语言和环境 Language and Environment
emitDecoratorMetadata,experimentalDecorators,默认值: false 为 ES 装饰器启用实验性支持 建议开启jsx,react 为 react-jsx
jsxFactory,
jsxFragmentFactory,
jsxImportSource,lib, Array
noLib,
reactNamespace,target: 默认 ‘es3’,推荐 ‘esnext’
useDefineForClassFields
Compiler Diagnostics
diagnostics,explainFiles,extendedDiagnostics,generateCpuProfile,listEmittedFiles,listFiles andtraceResolution
Projects
composite,disableReferencedProjectLoad,disableSolutionSearching,disableSourceOfProjectReferenceRedirect,incremental andtsBuildInfoFile
Output Formatting
noErrorTruncation,
preserveWatchOutput
pretty
Completeness
skipDefaultLibCheckskipLibCheck,默认值: false 跳过所有声明文件的类型检查(*.d.ts)
示例
{ |