Typescript-配置篇

在这里插入图片描述

简介

本篇文章主要是介绍typescript配置文件,并不会对typescript做讲解,想看typescript具体的介绍请看这个专栏链接

初始化项目
1、node.js  安装方法自行百度 
2、安装typescript  全局/局部
3、命令行tsc --init  初始化项目 
编译文件
1、tsc 和 tsc ./filename.ts 的区别
tsc指的是根据配置文件(tsconfig.json)编译typescript,而tsc ./filename.ts 直接编译typescr

2、include 编译指定文件
{
  "include": [
    "./demo1.ts",
  ]
}

3、exclude 不编译某个文件
{  "exclude": [
    "./demo2.ts"
  ],
}
编译规则

compilerOptions介绍

1、"removeComments": true, //去掉注释

2、"noImplicitAny": true,  //不显示的指明类型为any也可以,一般不建议用

3、"strictNullChecks": false,//不强制检查null类型

     let  null2  : string = null  //这样不会报错  一般不建议用
     
4、"target" :"ES5"  编译到ES的哪个版本例如es5

5、"allowJs": true //允许编译javascript文件

6、"checkJs": true, //检查.js文件中的错误

7、"sourceMap": true 生成source.map文件

以上是常用的配置参数具体请看链接,谢谢观看

猜你喜欢

转载自blog.csdn.net/handsomezhanghui/article/details/108054836
今日推荐