> ## :-: [编译选项查询表](https://www.cnblogs.com/zaihuilou/p/9556373.html) ## :-: 推荐配置 ``` { "compilerOptions": { "module": "commonjs" /* 指定模块代码生成: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "target": "es2016" /* 指定ECMAScript目标版本: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, "outDir": "./dist" /* 将输出结构重定向到目录。 */, "lib": ["esnext"] /* 指定要包含在编译中的库文件。 */, "esModuleInterop": true /* 支持CommonJS和ES模块之间的互操作性。 */, "removeComments": true /* 输出清除注释。 */, "noEmitOnError": true /* 报错时不生成输出文件 */, "isolatedModules": true /* 强制要求每一个ts文件必须是一个模块 */, "experimentalDecorators": true /* 实验修饰符 */, "emitDecoratorMetadata": true /* 给源码里的装饰器声明加上设计类型元数据 */, "strictNullChecks": true /* 在严格的null检查模式下,null和undefined值不包含在任何类型里,只允许用它们自己和any来赋值(有个例外,undefined可以赋值到void) */ // "strict": true /* 启用所有严格的类型检查选项。 */ }, "include": ["./src"] } ``` ## :-: tslint.json ``` // 安装 : yarn add -D tslint // 在项目根目录下创建 tslint.json 文件 { "defaultSeverity": "error", "extends": ["tslint:recommended"], "jsRules": {}, "rules": { "no-console": false, "no-empty": true, "interface-name": true, "no-shadowed-variable": false }, "rulesDirectory": [] } ```