tsconfig.json
文件包含了ts
编译选项,vue cli
脚手架生成的默认配置项如下
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}
compilerOptions
为编译器配置信息,全部配置选项见 这里
include, exclude
string[] 支持glob模式的路径列表,指定需要编译和不需要编译的文件路径
编译选项 (Compiler Options)
选项 | 类型 | 默认值 | 描述 |
---|---|---|---|
--target |
string |
"ES3" |
指定ECMAScript目标版本 "ES3" (默认), "ES5" , "ES6" / "ES2015" , "ES2016" , "ES2017" 或 "ESNext" 。 |
--module |
string |
target === "ES6" ? "ES6" : "commonjs" |
指定生成哪个模块系统代码: "None", "CommonJS", "AMD", "System", "UMD", "ES6"或 "ES2015"。 只有 "AMD"和 "System"能和 --outFile一起使用。 "ES6"和 "ES2015"可使用在目标输出为 "ES5"或更低的情况下。注意: "ESNext" 最新的生成目标列表为 ES proposed features
|
--strict |
boolean |
false |
启用所有严格类型检查选项。 启用 --strict 相当于启用--noImplicitAny , --noImplicitThis , --alwaysStrict , --strictNullChecks 和 --strictFunctionTypes 和--strictPropertyInitialization 。 |
--jsx |
string |
"Preserve" |
在 .tsx 文件里支持JSX: "React" 或 "Preserve" 。查看 JSX。 |
--importHelpers |
boolean |
从 tslib 导入辅助工具函数(比如 __extends , __rest 等) |
|
--moduleResolution |
string |
module === "AMD" or "System" or "ES6" ? "Classic" : "Node" |
决定如何处理模块。或者是"Node" 对于Node.js/io.js,或者是"Classic" (默认)。查看模块解析了解详情。 |
--experimentalDecorators |
boolean |
false |
启用实验性的ES装饰器。 |
--allowSyntheticDefaultImports |
boolean |
module === "system" 或设置了--esModuleInterop 且 module 不为 es2015 / esnext
|
允许从没有设置默认导出的模块中默认导入。这并不影响代码的输出,仅为了类型检查 |
--sourceMap |
boolean |
false |
生成相应的 .map文件。 |
--baseUrl |
string |
解析非相对模块名的基准目录。查看 模块解析文档了解详情。 | |
--types |
string[] |
要包含的类型声明文件名列表。查看 @types,--typeRoots和--types章节了解详细信息。 | |
paths |
Object |
模块名到基于 baseUrl 的路径映射的列表。查看 模块解析文档了解详情。 |
|
--lib |
string[] |
编译过程中需要引入的库文件的列表 |
网友评论