ts06_ts的编译选项1

tsconfig.json是ts编译器的配置文件,ts编译器可以根据它的信息来对代码进行编译。
可以执行 tsc --init命令自动生成
常用的配置选项:
include:定义希望被编译文件所在的目录,用来指定哪些ts文件需要被编译
默认值:["**/*"],
示列:["./src/**/*"],**表示任意文件夹,*表示任意文件
exclude:被排除的文件,不需要被编译的文件目录
 默认值:["node_moudles","bower_components","jspm.packages"]
extends:定义被继承的配置文件
示例:"extends":["./configs/base"]
上述示例中当前配置文件中会自动包含configs目录下base.json文件中的所有配置信息。
"files":指定需要被编译的文件列表
 示例:"files":["./part1/01_helloTS.ts"]
 
"compilerOptions":编译器的选项
compilerOptions内部的配置选项:
 "target":  /* 用来指定TS被编译为的ES版本,
 可选值:'es3', 'es5', 'es6','es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'esnext'.
 "module": ,  指定要使用的模块化的规范
  可选值: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.
  "lib": [],//lib用来指定项目中需要用到的库,一般情况下不需要改。
 "outDir": "./dist",//用来指定编译后文件所在的目录
 "outFile": "./dist/app.js",//将代码合并为一个文件,指定outfile后全局作用域中的代码会合并到同一文件中
 
{
  //tsconfig.json是ts编译器的配置文件,ts编译器可以根据它的信息来对代码进行编译,
  //配置选项:
  // include:定义希望被编译文件所在的目录,用来指定哪些ts文件需要被编译
  //默认值:["**/*"],
  // 示列:["./src/**/*"],**表示任意文件夹,*表示任意文件
  /*
  exclude:被排除的文件,不需要被编译的文件目录
  默认值:["node_moudles","bower_components","jspm.packages"]
  extends:定义被继承的配置文件
  示例:"extends":["./configs/base"]
  上述示例中当前配置文件中会自动包含configs目录下base.json文件中的所有配置信息。
  "files":指定需要被编译的文件列表
  示例:"files":["./part1/01_helloTS.ts"]
  */
  "include": [
    "./part2/**/*"
  ],
  "exclude": ["./part2/src/*"],
  /* 
   "compilerOptions":编译器的选项
  */
  "compilerOptions": {
  
    "target": "es6", /* 用来指定TS被编译为的ES版本,
    'es3', 'es5', 'es6', 
'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'esnext'. */
   
   /* "module": "system",  指定要使用的模块化的规范
     'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. */

    //  "lib": [],//lib用来指定项目中需要用到的库,一般情况下不需要改
    "outDir": "./dist",//用来指定编译后文件所在的目录
    "outFile": "./dist/app.js",//将代码合并为一个文件,指定outfile后全局作用域中的代码会合并到同一文件中
    "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
    "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
    "strict": true, /* Enable all strict type-checking options. */
    "skipLibCheck": true /* Skip type checking all .d.ts files. */
  }
}

 

 
posted @ 2022-12-23 18:29  SadicZhou  阅读(23)  评论(0编辑  收藏  举报