-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtsconfig.json
54 lines (48 loc) · 2.28 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
{
"compilerOptions": {
// Type Checking
// 严格的类型检查
"strict": true,
// Modules
// 设置解析非绝对路径模块名时的基准目录
// 但由于使用 Babel 进行转译,实际上这个配置不起作用
"baseUrl": "./",
// 设置程序的模块系统,通常是 es6 或者 commonjs
// 但由于使用 Babel 进行转译,总是编译成 commonjs,实际上这个配置不起作用
"module": "esnext",
// 指定模块解析策略
// 但由于使用 Babel 进行转译,实际上这个配置不起作用
"moduleResolution": "node",
// 将模块导入映射到相对于 baseUrl 路径
// 但由于使用 Babel 进行转译,需要配合 babel-plugin-module-resolver 一起使用
"paths": {},
// 支持解析 json 文件,提供类型支持
"resolveJsonModule": true,
// Emit
// 禁止 tsc 编译器生成文件,因为使用 Babel 来编译
"noEmit": true,
// JavaScript Support
// 允许在 ts 文件中引入 js 文件。
"allowJs": true,
// Interop Constraints
// 不会改变代码行为,只是确保每个 ts 文件都可以单独编译,因为 Babel 一次只能在一个文件上操作
"isolatedModules": true,
// 对导入 commonjs 的方式进行兼容,仅对类型检查起作用,让 TypeScript 的行为与 Babel 一致
"allowSyntheticDefaultImports": true,
// 对编译后的代码做兼容性处理,支持 import React from 'react' 这种方式导入 commonjs 模块
// 但因为使用 Babel 来编译, Babel 本身对 commonjs 有类似处理,所以这个配置实际上不起作用
"esModuleInterop": true,
// Language and Environment
// 控制 JSX 在 JavaScript 文件中的输出方式。这只影响 .tsx 文件的 JS 文件输出
// 但由于使用 Babel 进行转译,总是编译成 react 的模式,实际上这个配置不起作用
"jsx": "react-native",
// 使用最新的语法和 API,因为使用 Babel 来编译,仅影响类型检查
"target": "esnext",
// 为最新的语法和 API 提供类型支持
"lib": ["esnext"],
// Completeness
// 不检查第三方库的类型
"skipLibCheck": true
},
"exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]
}