typeScript 之(4) 编译选项

{
  /* 
  用来指定哪些ts文件需要被编译 
  ** 表示任意目录
  * 表示任意文件
  */
  "include":[    
    "./src/**/*"
  ],
  /* 不需要被编译的文件 */
  "exclude":[
    "./src/hello/**/*"
  ],
  "compilerOptions": {      
    /* 
    用来指定ts被编译的版本
    es3,es5,es6,es2015,es2016,es2017,es2018,es2019,es2020, 
    */
    "target": "es5",
    /* 
    指定模块化的规范 
    none,commonjs,and,system,umd,es6,es2015,es2020,esnext
    */
    "module": "system",
    /* 用来指定项目中要使用的库(一般不需要设置)  输入 xx报错 就会有提示类别*/
    "lib":[
      "dom","es6"/* nodejs是没有document的,但是想让这个对象在nodejs上运行 */
    ],
    /* 用来指定编译后文件所在的目录 */
    "outDir":"./dist",
    /*  
    将代码合并为一个文件 
    所有的全局作用域中的代码会合并到app.js
    只能是 system,and,amd
    */
    "outFile":"./dist/app.js",
    /* 是否对js文件进行编译,默认是false */
    "allowJs": false,
    /* 是否检查js代码是否符合ts语法规范 */
    "checkJs":false,
    /* 是否移除注释 */
    "removeComments": false,
    /* false:会生成,true:不生成  是否生成编译后的文件 比如dist文件夹会生成,但是里面的js就是不生成*/
    "noEmit":false,
    /*  当有错误时不生成编译后的文件  false:错误也会生成*/
    "noEmitOnError": false,
    /* 开启严格模式 true:开启*/
    "alwaysStrict": true,
    /* 不允许隐式的any类型  let e =10就是隐式的 */
    "noImplicitAny": true,
    /* 不允许不明确类型的this 
     function fn2(this:window)
     {
       console.log(this)
     }
    */
    "noImplicitThis": true,
    /* 严格的检测空值 
    let box1 = document.getElementById('box1');
    box1有可能为空值
    box1?.addEventListener('click',function(){
      alert('hello')
    })
    */
    "strictNullChecks": false,
      /* 所有严格检查的总开关 */
      "strict": false,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}
原文地址:https://www.cnblogs.com/zmztya/p/14718194.html