tsconfig.json配置详解

233 阅读1分钟
{
  // 用来指定哪些ts文件需要被编译
  // 路径:/** 表示任意目录  /* 表示任意文件  
  "include": [
    "./**/*"
  ],
  "exclude": [
    "./hello.ts"
  ],
  //  编译器的选项 
  "compilerOptions": {
    
    "target": "ES3",  // 用来指定ts编译后es的版本
    
    "module": "es2015",  // module 用来指定使用模块化的规范
    
    // "lib": []  // lib 用来指定项目中要使用的库
    
    "outDir": "./dist",  // outDIr 用来指定编译后文件所在的目录
    
    // "outFile": "./dist/app.js",  // outFile 用来将全局化代码合并为一个文件
    
    "allowJs": true,  // 是否对JS进行编译,默认为false
    
    "checkJs": false,  // 检查JS代码是否符合语法规范,默认为false
    
    "removeComments": false,  // 是否移除注释,默认为false
    
    "noEmit": false,  // 不生成编译后的文件,默认为false 
    
    "noEmitOnError": false,  // 当有错误时,不生成编译后的文件,默认为false 
    
    "alwaysStrict": false,  // 用来设置编译后的文件是否使用严格模式,默认为false 
    
    "noImplicitAny": false,  // 不允许隐式的any类型,默认为false 
    
    "noImplicitThis": false,  // 不允许不明确类型的this,默认为false 
    
    "strictNullChecks": false  // 严格检查空值,默认为false 
  } 
}