tsconfig.json文件配置说明
1. tsconfig.json文件中的选项配置
TypeScript编译器配置文件的JSON模式
{
"title": "JSON schema for the TypeScript compiler's configuration file",
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"filesDefinition": {
"properties": {
"files": {
"description": "如果tsconfig.json文件中不存在files或者include属性, 则编译器包括包含目录和子目录中的所有文件,exclude属性指定的文件除外. 当指定files属性时, 仅包括files属性指定的文件和include属性指定的文件.",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"excludeDefinition": {
"properties": {
"exclude": {
"description": "指定要排除在编译之外的文件列表. exclude属性仅仅影响include属性包含的文件,而不影响files属性. 全局模式需要TypeScript 2.0或更改版本.",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"includeDefinition": {
"properties": {
"include": {
"description": "Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later.",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"compileOnSaveDefinition": {
"properties": {
"compileOnSave": {
"description": "Enable Compile-on-Save for this project.",
"type": "boolean"
}
}
},
"extendsDefinition": {
"properties": {
"extends": {
"description": "Path to base configuration file to inherit from. Requires TypeScript version 2.1 or later.",
"type": "string"
}
}
},
"compilerOptionsDefinition": {
"properties": {
"compilerOptions": {
"type": "object",
"description": "Instructs the TypeScript compiler how to compile .ts files.",
"properties": {
"charset": {
"description": "The character set of the input files.",
"type": "string"
},
"composite": {
"description": "Enables building for project references.",
"type": "boolean"
},
"declaration": {
"description": "Generates corresponding d.ts files.",
"type": "boolean"
},
"declarationDir": {
"type": "string",
"description": "Specify output directory for generated declaration files. Requires TypeScript version 2.0 or later."
},
"diagnostics": {
"description": "Show diagnostic information.",
"type": "boolean"
},
"emitBOM": {
"description": "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.",
"type": "boolean"
},
"emitDeclarationOnly": {
"description": "Only emit '.d.ts' declaration files.",
"type": "boolean"
},
"incremental": {
"description": "启用增量编译.",
"type": "boolean"
},
"tsBuildInfoFile": {
"description": "指定用于存储增量编译信息的文件.",
"type": "string"
},
"inlineSourceMap": {
"description": "Emit a single file with source maps instead of having a separate file.",
"type": "boolean"
},
"inlineSources": {
"description": "Emit the source alongside the sourcemaps within a single file; requires --inlineSourceMap to be set.",
"type": "boolean"
},
"jsx": {
"description": "Specify JSX code generation: 'preserve', 'react', or 'react-native'.",
"enum": [ "preserve", "react", "react-native" ]
},
"reactNamespace": {
"description": "Specifies the object invoked for createElement and __spread when targeting 'react' JSX emit.",
"type": "string"
},
"listFiles": {
"description": "Print names of files part of the compilation.",
"type": "boolean"
},

本文深入探讨了TypeScript的配置文件tsconfig.json的选项,包括编译器选项、全局路径映射等关键配置。详细解释了如编译、输出、模块解析、严格类型检查等设置,旨在帮助开发者更好地理解和优化TypeScript项目构建过程。
最低0.47元/天 解锁文章
46

被折叠的 条评论
为什么被折叠?



