4

【笔记】TS编译器配置

 1 year ago
source link: https://loli.fj.cn/2023/06/07/TS%E7%BC%96%E8%AF%91%E5%99%A8%E9%85%8D%E7%BD%AE/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

TS编译器配置学习笔记

TS编译器配置文件

  • TS编译器tsc会根据当前目录下的tsconfig.json配置文件进行编译

include:指定包含,被指定的文件都会被编译

**:任意目录
*:任意文件

include:指定不包含,被指定的文件都不会被编译
extends:继承配置,继承被指定的配置文件
files:指定需要被编译的单个ts文件
compilerOptions:编译器选项

target:编译的JS版本,默认为ES3

ES3ES5ES6ES2015ES2016ES2017ES2018ES2019ES2020ESNext

module:模块化规范

nonecommonjsamdsystemumdes6ES2015ES2020ESNext

lib:指定用到的库
outDir:编译后的JS存放的目录
outFile:合并所有ts编译后的文件为一个JS文件,指定这个文件的存放路径
allowJs:是都将JS文件编译,默认为false
checkJs:是否检查JS文件的语法是否符合TS规范,默认为false
removeComments:是否在编译时移除注释,默认为false
noEmit:是否不生成编译后的JS文件,默认为false
noEmitOnError:出错时是否不生成编译后的JS文件,默认为false
alwaysStrict:是否在编译后的JS文件使用严格模式,默认为false
noImplicitAny:是否在TS文件中不允许隐式的any类型,默认为false
noImplicitThis:是否在TS文件中不允许不明确的this,默认为false
strictNullChecks:是否严格的检查空值,默认为false
strict:是否开启所有的严格检查,默认为false

{
"include": [
"./src/**/*"
],
"exclude": [],
"include": "",
"files": [],
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"lib": ["dom"],
"outDir": "./dist",
"outFile": "./dist/app.js",
"allowJs": false,
"checkJs": false,
"removeComments": false,
"noEmit": false,
"alwaysStrict": false,
"noImplicitAny": false,
"noImplicitThis": false,
"strictNullChecks": false,
"strict": false
}
}

哔哩哔哩——尚硅谷


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK