美文网首页
tsconfig.json

tsconfig.json

作者: 戊戌水瓶 | 来源:发表于2021-03-08 14:05 被阅读0次

    使用命令行创建tsconfig.json文件: tsc -init

    1、"include": ["demo.ts",....],  // 数组内的文件都编译,与"files"作用相同

           "exclue": ["demo.ts",....],  // 数组内的文件都不编译 

    2、"removeComments": true/false  编译出来的js文件是否显示注释
    3、"strict" 编译译和书写规范,是否按照TypeScript最严格的规范来写(一般设置为true即可)

          若strict为true,则下面的一串(noImplicitAny、strictNullChecks...alwaysStrict)也为true

      3.1 noImplicitAny 允许你的注解类型any不用特意表明,若noImplicitAny为true:

              function hello(name:any) {return name;}  不能去掉粗体部分

      3.2 strictNullChecks:强制检查NULL类型,若noImplicitAny为true:

              const usname:string=null; 会报错

    4、"outDir": "./build", 编译完成的文件放到哪个目录下

          "rootDir": "./src",    要编译的ts文件在哪个目录

    5、"sourceMap": true, ts和js文件对应的信息

    6、"noUnusedLocals": true,  未使用属性编译会报错

    其他配置编译选项查看

    https://www.tslang.cn/docs/handbook/compiler-options.html 

    相关文章

      网友评论

          本文标题:tsconfig.json

          本文链接:https://www.haomeiwen.com/subject/xncpqltx.html