- allowUnreachableCode">allowUnreachableCode
- allowUnusedLabels">allowUnusedLabels
- assumeChangesOnlyAffectDirectDependencies">assumeChangesOnlyAffectDirectDependencies
- charset">charset
- declarationDir">declarationDir
- diagnostics">diagnostics
- disableReferencedProjectLoad">disableReferencedProjectLoad
- explainFiles">explainFiles
- extendedDiagnostics">extendedDiagnostics
- traceResolution">traceResolution
- useDefineForClassFields">useDefineForClassFields
调试相关的选项。
allowUnreachableCode
默认:undefined
选项:
undefined
(default) 编辑器提供warningtrue
unreachable 代码会忽略false
unreachable 代码会报错
function fn(n: number) {
if (n > 5) {
return true;
} else {
return false;
}
return true;
// error: Unreachable code detected.
}
allowUnusedLabels
默认:undefined
选项:
undefined
(default) 编辑器提供warningtrue
unused labels 代码会忽略false
unused labels 代码会报错
function verifyAge(age: number) {
// Forgot 'return' statement
if (age > 18) {
verified: true;
// error: Unused label.
}
}
assumeChangesOnlyAffectDirectDependencies
当这个选项被启用时,TypeScript将避免重新检查/重建所有真正可能受到影响的文件,而只会重新检查/重建已经发生变化的文件以及直接导入它们的文件。
这可以被认为是监视算法的一个“快速而松散”的实现,它可以极大地减少增量重建时间,代价是必须偶尔运行完整构建以获得所有编译器错误消息。
charset
- 弃用
- 默认:
utf8
declarationDir
声明文件的文件位置
{
"compilerOptions": {
"declaration": true,
"declarationDir": "./types"
}
}
在 types
文件夹里放置声明文件 index.d.ts
example
├── index.js
├── index.ts
├── package.json
├── tsconfig.json
└── types
└── index.d.ts
diagnostics
- 弃用
- 默认:false
用于输出诊断信息进行调试。
disableReferencedProjectLoad
disableSizeLimit,
disableSolutionSearching,
disableSourceOfProjectReferenceRedirect,
emitBOM,
emitDeclarationOnly,
explainFiles
extendedDiagnostics
forceConsistentCasingInFileNames,
generateCpuProfile,
importsNotUsedAsValues,
jsxFactory,
jsxFragmentFactory,
jsxImportSource,
keyofStringsOnly,
listEmittedFiles,
listFiles,
maxNodeModuleJsDepth,
newLine,
noEmitHelpers,
noEmitOnError,
noErrorTruncation,
noImplicitUseStrict,
noLib,
noResolve,
noStrictGenericChecks,
out,
preserveConstEnums,
reactNamespace,
resolveJsonModule,
skipDefaultLibCheck,
skipLibCheck,
stripInternal,
suppressExcessPropertyErrors,
suppressImplicitAnyIndexErrors,
traceResolution
跟踪为什么debug某模块却没有被包含的原因。
具体可以看:Tracing module resolution