-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsconfig.json
96 lines (95 loc) · 5.91 KB
/
tsconfig.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
"compilerOptions": {
// // 开启类型定义文件生成的开关
// "noEmit": false,
// "declaration": true,
// // 类型定义文件生成的目标目录
// "outDir": "types",
// // 只emit类型定义文件,而不emit其他诸如source-map等
// "emitDeclarationOnly": true,
// 社区也有相关的vite插件,插件地址。实现原理是使用ts-morph生成相应的类型申明文件。感兴趣的读者可以自行尝试。
// "incremental": true, // TS编译器在第一次编译之后会生成一个存储编译信息的文件,第二次编译会在第一次的基础上进行增量编译,可以提高编译的速度
// "tsBuildInfoFile": "./buildFile", // 增量编译文件的存储位置
"diagnostics": true, // 打印诊断信息
"target": "esnext", // 目标语言的版本, 与 Vue 的浏览器支持保持一致
"module": "CommonJS", // 生成代码的模板标准
// "module": "esnext",
// "outFile": "./app.js", // 将多个相互依赖的文件生成一个文件,可以用在AMD模块中,即开启时应设置"module": "AMD",
// "lib": ["DOM", "ES2015", "ScriptHost", "ES2019.Array"], // TS需要引用的库,即声明文件,es5 默认引用dom、es5、scripthost,如需要使用es的高级版本特性,通常都需要配置,如es8的数组新特性需要引入"ES2019.Array",
// "allowJS": true, // 允许编译器编译JS,JSX文件
// "checkJs": true, // 允许在JS文件中报错,通常与allowJS一起使用
// "outDir": "./dist", // 指定输出目录
// "rootDir": "./", // 指定输出文件目录(用于输出),用于控制输出目录结构
// "declaration": false, // 生成声明文件,开启后会自动生成声明文件
// "declarationDir": "./file", // 指定生成声明文件存放目录
// "emitDeclarationOnly": true, // 只生成声明文件,而不会生成js文件
// "sourceMap": true, // 生成目标文件的sourceMap文件
// "inlineSourceMap": true, // 生成目标文件的inline SourceMap,inline SourceMap会包含在生成的js文件中
// "declarationMap": true, // 为声明文件生成sourceMap
// "removeComments":true, // 删除注释
// "noEmit": true, // 不输出文件,即编译后不会生成任何js文件
// "noEmitOnError": true, // 发送错误时不输出任何文件
// "noEmitHelpers": true, // 不生成helper函数,减小体积,需要额外安装,常配合importHelpers一起使用
// "importHelpers": true, // 通过tslib引入helper函数,文件必须是模块
// "downlevelIteration": true, // 降级遍历器实现,如果目标源是es3/5,那么遍历器会有降级的实现
// "strict": true, // 开启所有严格的类型检查
// "alwaysStrict": true, // 在代码中注入'use strict'
// "noImplicitAny": true, // 不允许隐式的any类型
// "strictNullChecks": true, // 不允许把null、undefined赋值给其他类型的变量
// "strictFunctionTypes": true, // 不允许函数参数双向协变
// "strictPropertyInitialization": true, // 类的实例属性必须初始化
// "strictBindCallApply": true, // 严格的bind/call/apply检查
// "noImplicitThis": true, // 不允许this有隐式的any类型
// "noUnusedLocals": true, // 检查只声明、未使用的局部变量(只提示不报错)
// "noUnusedParameters": true, // 检查未使用的函数参数(只提示不报错)
// "noFallthroughCasesInSwitch": true, // 防止switch语句贯穿(即如果没有break语句后面不会执行)
// "noImplicitReturns": true, //每个分支都会有返回值
// "esModuleInterop": true, // 允许export=导出,由import from 导入
// "allowUmdGlobalAccess": true, // 允许在模块中全局变量的方式访问umd模块
// "moduleResolution": "node", // 模块解析策略,ts默认用node的解析策略,即相对的方式导入
// "baseUrl": "./", // 解析非相对模块的基地址,默认是当前目录
// "paths": { // 路径映射,相对于baseUrl
// // 如使用jq时不想使用默认版本,而需要手动指定版本,可进行如下配置
// "jquery": ["node_modules/jquery/dist/jquery.min.js"]
// },
// "rootDirs": ["src","out"], // 将多个目录放在一个虚拟目录下,用于运行时,即编译后引入文件的位置可能发生变化,这也设置可以虚拟src和out在同一个目录下,不用再去改变路径也不会报错
// "listEmittedFiles": true, // 打印输出文件
// "listFiles": true// 打印编译的文件(包括引用的声明文件)
// 这可以对 `this` 上的数据 property 进行更严格的推断
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true, // true允许从没有默认导出的模块引入
"resolveJsonModule": true,
"sourceMap": true,
"baseUrl": ".",
// "types": ["element-plus/global.d.ts"],// 加载的声明文件包
"paths": {
"utils/*": ["src/common/utils/*"],
"store/*": ["src/store/*"],
"@/*": ["src/*"],
"static/*": ["static/*"],
"root/*": ["*"]
},
"lib": ["esnext", "es2020", "dom", "dom.iterable", "scripthost"],
"typeRoots": ["shims-vue.d.ts", "node_modules/@types"]// 声明文件目录,默认时node_modules/@types
},
"files": ["shims-vue.d.ts"],
"include": [
"src/**/*.d.ts",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"components/**/*.d.ts",
"components/**/*.ts",
"components/**/*.tsx",
"components/**/*.vue",
"env.d.ts",
"components/**/index.d.ts",
],
"exclude": ["node_modules"]
}