tsconfig.json参考手册

Visit https://aka.ms/tsconfig to read more about this file

项目默认值说明
Projects
"incremental"trueSave .tsbuildinfo files to allow for incremental compilation of projects.保存.tsbuildinfo文件以允许增量编译项目。
"composite"trueEnable constraints that allow a TypeScript project to be used with project references.启用允许TypeScript项目与项目引用一起使用的约束。
"tsBuildInfoFile""./.tsbuildinfo"Specify the path to .tsbuildinfo incremental compilation file.指定.tsbuildinfo增量编译文件的路径。
"disableSourceOfProjectReferenceRedirect"trueDisable preferring source files instead of declaration files when referencing composite projects.在引用复合项目时,禁用首选源文件而不是声明文件。
"disableSolutionSearching"trueOpt a project out of multi-project reference checking when editing.编辑时将项目从多项目参照检查中选择出来。
"disableReferencedProjectLoad"trueReduce the number of projects loaded automatically by TypeScript.减少TypeScript自动加载的项目数量。
Language and Environment
"target""es2022"Set the JavaScript language version for emitted JavaScript and include compatible library declarations.为已发出的JavaScript设置JavaScript语言版本,并包含兼容的库声明。
"lib"[]Specify a set of bundled library declaration files that describe the target runtime environment.指定一组描述目标运行时环境的绑定库声明文件。
"jsx""preserve"Specify what JSX code is generated.指定生成的JSX代码。
"experimentalDecorators"trueEnable experimental support for legacy experimental decorators.启用对遗留实验性装饰器的实验性支持。
"emitDecoratorMetadata"trueEmit design-type metadata for decorated declarations in source files.为源文件中的修饰声明发出设计类型元数据。
"jsxFactory"""Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'.指定针对React JSX发射时使用的JSX工厂函数,例如“ReactcreateElement”或“h”。
"jsxFragmentFactory"""Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.指定针对React JSX发射时用于片段的JSX片段引用,例如“ReactFragment”或“Fragment“。
"jsxImportSource"""Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'.指定在使用“jsx: react-jsx*”时用于导入JSX工厂函数的模块说明符。
"reactNamespace"""Specify the object invoked for 'createElement'. 指定为“createElement”调用的对象。This only applies when targeting 'react' JSX emit.这仅适用于以“反应”JSX发射为目标的情况。
"noLib"trueDisable including any library files, including the default lib.d.ts.禁用包含任何库文件,包括默认的lib.dt.s。
"useDefineForClassFields"trueEmit ECMAScript-standard-compliant class fields.发出符合ECMAScript标准的类字段。
"moduleDetection""auto"Control what method is used to detect module-format JS files.控制使用何种方法检测模块格式的JS文件。
Modules
"module""commonjs"Specify what module code is generated.指定生成的模块代码。
"rootDir""./src"Specify the root folder within your source files.指定源文件中的根文件夹。
"moduleResolution""node"Specify how TypeScript looks up a file from a given module specifier.指定TypeScript如何从给定的模块说明符中查找文件。
"baseUrl""./"Specify the base directory to resolve non-relative module names.指定用于解析非相对模块名称的基本目录。
"paths"{}Specify a set of entries that re-map imports to additional lookup locations.指定一组条目,用于将导入重新映射到其他查找位置。
"rootDirs"[]Allow multiple folders to be treated as one when resolving modules.在解析模块时,允许将多个文件夹视为一个文件夹。
"typeRoots"[]Specify multiple folders that act like './node_modules/@types'.指定多个类似“./node_modules/@types”的文件夹。
"types"[]Specify type package names to be included without being referenced in a source file.指定要包含的类型包名称,而不在源文件中引用。
"allowUmdGlobalAccess"trueAllow accessing UMD globals from modules.允许从模块访问UMD全局。
"moduleSuffixes"[]List of file name suffixes to search when resolving a module.解析模块时要搜索的文件名后缀列表。
"allowImportingTsExtensions"trueAllow imports to include TypeScript file extensions. 允许导入包含TypeScript文件扩展名。Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.要求设置“--moduleSolution bundler”和“--noEmit”或“--emitDeclarationOnly”。
"resolvePackageJsonExports"trueUse the package.json 'exports' field when resolving package imports.解析包导入时,请使用package.json“exports”字段。
"resolvePackageJsonImports"trueUse the package.json 'imports' field when resolving imports.解析导入时使用package.json“imports”字段。
"customConditions"[]Conditions to set in addition to the resolver-specific defaults when resolving imports.在解析导入时,除了解析程序特定的默认值之外,还要设置的条件。
"resolveJsonModule"trueEnable importing .json files.启用导入.json文件。
"allowArbitraryExtensions"trueEnable importing files with any extension, provided a declaration file is present.如果存在声明文件,则启用导入任何扩展名的文件。
"noResolve"trueDisallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project.禁止“import”、“require”或“<reference>”扩展TypeScript应添加到项目中的文件数。
JavaScript Support
"allowJs"trueAllow JavaScript files to be a part of your program. 允许JavaScript文件成为程序的一部分。Use the 'checkJS' option to get errors from these files.使用“checkJS”选项可以从这些文件中获取错误。
"checkJs"trueEnable error reporting in type-checked JavaScript files.在类型检查的JavaScript文件中启用错误报告。
"maxNodeModuleJsDepth"1Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. 指定用于检查“node_modules”中JavaScript文件的最大文件夹深度。Only applicable with 'allowJs'.仅适用于“allowJs”。
Emit
"declaration"trueGenerate .d.ts files from TypeScript and JavaScript files in your project.从项目中的TypeScript和JavaScript文件生成.d.ts文件。
"declarationMap"trueCreate sourcemaps for d.ts files.为d.ts文件创建源映射。
"emitDeclarationOnly"trueOnly output d.ts files and not JavaScript files.只输出d.ts文件,不输出JavaScript文件。
"sourceMap"trueCreate source map files for emitted JavaScript files.为发出的JavaScript文件创建源映射文件。
"inlineSourceMap"trueInclude sourcemap files inside the emitted JavaScript.在发出的JavaScript中包含源映射文件。
"outFile""./"Specify a file that bundles all outputs into one JavaScript file. 指定一个将所有输出捆绑到一个JavaScript文件中的文件。If 'declaration' is true, also designates a file that bundles all .d.ts output.如果“declaration”为true,还指定一个绑定所有.d.ts输出的文件。
"outDir""./dist"Specify an output folder for all emitted files.为所有发出的文件指定一个输出文件夹。
"removeComments"trueDisable emitting comments.禁用发出评论。
"noEmit"trueDisable emitting files from a compilation.禁用从编译中发出文件。
"importHelpers"trueAllow importing helper functions from tslib once per project, instead of including them per-file.允许每个项目从tslib导入一次辅助函数,而不是每个文件都包含这些函数。
"importsNotUsedAsValues""remove"Specify emit/checking behavior for imports that are only used for types.为仅用于类型的导入指定发出/检查行为。
"downlevelIteration"trueEmit more compliant, but verbose and less performant JavaScript for iteration.为迭代发出更兼容但冗长且性能较差的JavaScript。
"sourceRoot"""Specify the root path for debuggers to find the reference source code.指定调试器查找引用源代码的根路径。
"mapRoot"""Specify the location where debugger should locate map files instead of generated locations.指定调试器应定位映射文件的位置,而不是生成的位置。
"inlineSources"trueInclude source code in the sourcemaps inside the emitted JavaScript.在发出的JavaScript中的源映射中包含源代码。
"emitBOM"trueEmit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.在输出文件的开头发出UTF-8字节顺序标记(BOM)。
"newLine""crlf"Set the newline character for emitting files.设置发出文件的换行符。
"stripInternal"trueDisable emitting declarations that have '@internal' in their JSDoc comments.禁用在其JSDoc注释中包含“@internal”的发出声明。
"noEmitHelpers"trueDisable generating custom helper functions like '__extends' in compiled output.禁用在编译的输出中生成自定义帮助程序函数,如“__extends”。
"noEmitOnError"trueDisable emitting files if any type checking errors are reported.如果报告了任何类型检查错误,则禁用发送文件。
"preserveConstEnums"trueDisable erasing 'const enum' declarations in generated code.禁用在生成的代码中擦除“const enum”声明。
"declarationDir""./"Specify the output directory for generated declaration files.为生成的声明文件指定输出目录。
"preserveValueImports"truePreserve unused imported values in the JavaScript output that would otherwise be removed.在JavaScript输出中保留未使用的导入值,否则这些值将被删除。
Interop Constraints
"isolatedModules"trueEnsure that each file can be safely transpiled without relying on other imports.确保每个文件都可以在不依赖其他导入的情况下安全地进行传输。
"verbatimModuleSyntax"trueDo not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting.不要转换或消除任何未标记为仅类型的导入或导出,确保它们以基于“module”设置的输出文件格式编写。
"allowSyntheticDefaultImports"trueAllow 'import x from y' when a module doesn't have a default export.当模块没有默认导出时,允许“从y导入x”。
"esModuleInterop"trueEmit additional JavaScript to ease support for importing CommonJS modules. 发出额外的JavaScript以简化对导入CommonJS模块的支持。This enables 'allowSyntheticDefaultImports' for type compatibility.这为类型兼容性启用了“allowSyntheticDefaultImports”。
"preserveSymlinks"trueDisable resolving symlinks to their realpath. This correlates to the same flag in node.禁用将符号链接解析为其真实路径。这与节点中的相同标志相关。
"forceConsistentCasingInFileNames"trueEnsure that casing is correct in imports.确保套管在进口时是正确的。
Type Checking
"strict"trueEnable all strict type-checking options.启用所有严格的类型检查选项。
"noImplicitAny"trueEnable error reporting for expressions and declarations with an implied 'any' type.为具有隐含“any”类型的表达式和声明启用错误报告。
"strictNullChecks"trueWhen type checking, take into account 'null' and 'undefined'.在类型检查时,请考虑“null”和“undefined”。
"strictFunctionTypes"trueWhen assigning functions, check to ensure parameters and the return values are subtype-compatible.分配函数时,请检查以确保参数和返回值与子类型兼容。
"strictBindCallApply"trueCheck that the arguments for 'bind', 'call', and 'apply' methods match the original function.请检查“bind”、“call”和“apply”方法的参数是否与原始函数匹配。
"strictPropertyInitialization"trueCheck for class properties that are declared but not set in the constructor.检查构造函数中已声明但未设置的类属性。
"noImplicitThis"trueEnable error reporting when 'this' is given the type 'any'.当“this”的类型为“any”时,启用错误报告。
"useUnknownInCatchVariables"trueDefault catch clause variables as 'unknown' instead of 'any'.将catch子句变量默认为“unknown”,而不是“any”。
"alwaysStrict"trueEnsure 'use strict' is always emitted.确保始终发出“use strict”。
"noUnusedLocals"trueEnable error reporting when local variables aren't read.在未读取本地变量时启用错误报告。
"noUnusedParameters"trueRaise an error when a function parameter isn't read.未读取函数参数时引发错误。
"exactOptionalPropertyTypes"trueInterpret optional property types as written, rather than adding 'undefined'.将可选属性类型解释为写入的,而不是添加“未定义”。
"noImplicitReturns"trueEnable error reporting for codepaths that do not explicitly return in a function.为函数中未显式返回的代码路径启用错误报告。
"noFallthroughCasesInSwitch"trueEnable error reporting for fallthrough cases in switch statements.为switch语句中的失败情况启用错误报告。
"noUncheckedIndexedAccess"trueAdd 'undefined' to a type when accessed using an index.使用索引访问时,将“undefined”添加到类型中。
"noImplicitOverride"trueEnsure overriding members in derived classes are marked with an override modifier.确保用重写修饰符标记派生类中的重写成员。
"noPropertyAccessFromIndexSignature"trueEnforces using indexed accessors for keys declared using an indexed type.对使用索引类型声明的键强制使用索引访问器。
"allowUnusedLabels"trueDisable error reporting for unused labels.禁用未使用标签的错误报告。
"allowUnreachableCode"trueDisable error reporting for unreachable code.禁用无法访问的代码的错误报告。
Completeness
"skipDefaultLibCheck"trueSkip type checking .d.ts files that are included with TypeScript.跳过TypeScript中包含的类型检查.d.ts文件。
"skipLibCheck"trueSkip type checking all .d.ts files.跳过对所有.d.ts文件的类型检查。