tsconfig.json配置
/**
tsconfig.json是ts编译器的配置文件,ts编译器可以根据他的信息来对代码进行编译
*/
{
/* "include"指定哪些文件需要被编译
"*" 表示任意文件
"**" 表示任意目录
*/
"include": [
// 表示src的任意目录下的任意文件
"./src/**/*",
"index.ts",
"index.ts",
"test.ts",
"test.ts"
],
/* "exclude"指定哪些文件不包含
"*" 表示任意文件
"**" 表示任意目录
*/
"exclude": [
"./src/test/**/*"
],
/* "extends"定义被继承的配置文件
*/
"extends": "./config/base.json",
/*
files指定被编译的文件列表,只有需要编译的文件少时才会用到
*/
"files": [
"test.ts",
"index.ts"
],
/*
"compilerOptions"编译器的选项:
*/
"compilerOptions": {
/* 编译成js文件的目标代码版本,ESNext最新版本
--target, -t
Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
one of: es3, es5, es6/es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, esnext
default: es5
*/
"target": "ES5",
/*
module 指定模块化的规范
--module, -m Specify what module code is generated.
one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext
default: undefined
**/
"module": "es2015",
/*
lib 指定所使用的库
--lib Specify a set of bundled library declaration files that describe the target runtime environment.
one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, e
s2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynci
terable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol,
es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.in
tl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp,
es2023.array/esnext.array, esnext.intl, decorators, decorators.legacy
default: undefined
**/
"lib": [
"DOM"
],
/**
"outDir":编译文件的输出路径
*/
"outDir": "./dist",
/**
"outFile":将代码合并为一个文件,仅仅在modules设置为'amd','system'有效
Only 'amd' and 'system' modules are supported alongside --outFile.
*/
// "outFile": "./dist/index.js"
/**
"allowJs":是否编译js文件,默认为false
*/
"allowJs": false,
/**
"checkJs":检查JS代码是否符合规则
*/
"checkJs": false,
/**
"removeComments":移除注释
*/
"removeComments": false,
/**
"noEmit":不生成编译后的文件
*/
"noEmit": false,
/**
"noEmitOnError":当有错误时候不生成编译后的文件
*/
"noEmitOnError": true,
/**
"strict":所有严格检查的总开关
true:所有的严格检查打开
false:所有的严格检查关闭
*/
"strict": false,
/**
"alwaysStrict":编译后的文件启用严格模式,在浏览器可以提高性能"use strict"
*/
"alwaysStrict": true,
/**
"noImplicitAny":当不指定类型时,不允许变量的类型为隐式any
*/
"noImplicitAny": false,
/**
"noImplicitThis":检查隐式类型的this,不允许不明确类型的this
*/
"noImplicitThis": true,
/**
"strictNullChecks":严格的空对象检查
*/
"strictNullChecks": false,
},
}