作用:指定项目文件和项目编译所需的配置项。
生成命令:tsc --init
文件解析:
{
"compilerOptions": {
"target": "es5", // 生成代码的语言版本
"lib": [
"dom",
"dom.iterable",
"esnext"
], // 指定要包含在编译中的 library
"allowJs": true, // 允许 ts 编译器编译 js 文件
"skipLibCheck": true, // 跳过声明文件的类型检查
"esModuleInterop": true, // es 模块互操作,屏蔽 ESModule 和 CommonJS 之间的差异
"allowSyntheticDefaultImports": true, // 允许通过 import x from 'y' 及时模块没有显式指定 default 导出
"strict": true, // 开启严格模式
"forceConsistentCasingInFileNames": true, // 对文件名称强制区分大小写
"noFallthroughCasesInSwitch": true, // 为 switch 语句启用错误报告
"module": "esnext", // 生成代码的模块化标准
"moduleResolution": "node", //模块解析(查找)策略
"resolveJsonModule": true, // 允许导入扩展名为 .json 的模块
"isolatedModules": true, // 是否将没有 import/export 文件市委旧(全局而非模块化)脚本文件
"noEmit": true, // 编译时不生成任何文件(只进行类型检查)
"jsx": "react-jsx" // 指定将 JSX 编译成什么形式
},
"include": [
"src"
] // 指定允许 ts 处理的目录
}