typescript--2 ts编译器的配置文件

187 阅读1分钟

在使用 tsc 命令来编辑 ts 文件时,需要配置的tsconfig.json 文件

{
    include:[], // 指定哪些文件需要被编辑, 里面是文件的路径
    exclude:[], // 指定哪些文件不需要被编辑, /** 任意目录 *表示任意文件
    extends:"", // 被继承的文件路径
    files: [], // 和include 相似 这个设置的是文件名
    compilerOptions: {
        target: 'es3', // 用来指定被编译的版本
        module: "",  // 指定使用模块化标准  ES20155  common amd system ...
        lib: [],   // 用来指定项目中使用的库  一般不动
        outDir: "", // 用来指定编译后的文件的存放路径
        outFile: "",  // 将代码合并为一个文件, 合并模块需要 module 为 amd 
        allowJs: false,  // 是否对js 文件编译
        checkJs: false,  // 是否检查js  代码是否符合语法规范
        removeComments: true,  // 是否移除注释
        noEmit: false,   // 不生成编译后的文件
        noEmitOnError: true,  // 当有错误的时候 不编译
        alwaysStrict: false,  // 编译后的文件 使用严格模式
        noImplicitAny: true,  // 不允许隐式any 类型
        noImplicitThis: true, // 不允许不明确类型的this
        strictNullChecks: true, // 严格的检查空值
        strict: true           // 所有严格检查总开关
    }
}