当前位置:网站首页>typescript 编译选项和配置文件
typescript 编译选项和配置文件
2022-06-11 11:28:00 【Michael18811380328】
typescript 编译选项和配置文件
使用 TS 完成前端项目时,通常需要把 TS 编译成不同版本的 JS,然后和其他文件进行共同使用。
配置文件说明
配置项放在 tsconfig.json 中,主要包含下面的配置
* 有 tsconfig.json 文件的目录是一个 Typescript 项目
* tsc 没有输入文件
:从当前位置往上找 tsconfig.json
:--project 目录(包含 tsconfig.json) | .json 文件
* 有输入文件则忽略 tsconfig.json
* 属性 files:要编译的文件
* 属性 include:包含的文件
* 属性 exclude:排除的文件
* 属性 compilerOptions:编译选项
* glob-like file patterns,水滴模式
:* = 零个或多个字符(不包括目录分隔符)
:? = 一个字符
:**/ = 递归匹配子目录
:(* or .*)匹配 .ts, .tsx, .d.ts 和 .jsx(allowJs = true)
* 没有指定 files 和 include:当前目录和子目录中的 typescript 文件
* 同时指定 files 和 include:取并集
* 没有指定 exclude,默认排除 outDir
* exclude 可以排除 include,不能排除 files
* exclude 默认 node_modules, bower_components, jspm_packages and <outDir>
* 引用的文件也会被包括
* 有可能的输入文件不会被包括,不建议使用同名文件(不同扩展名)
* tsconfig.json 空的也可以
* 命令行选项优先
* node_modules/@types 会被包括,一直往上类推
* typeRoots 限制了根目录
* types 在的话,只有指定的才会被包括 ./node_modules/@types/node ...、
* type package:1)有 index.d.ts 的文件夹;2)package.json that has a types field
* 自动包含只有在 全局声明 才重要,使用 import 不需要
* 属性 extends 可以继承配置
* extends 是顶级属性,值为 另一个配置文件的路径
* 本地配置覆盖继承配置,互相继承会报错
* 路径相对于各个配置文件
* compileOnSave:顶级属性,目前只对 VS2015以上有效
编译选项说明
编译选项,指的是编译过程中,需要怎么操作
typescript 编译选项
-- allowJs = false:js文件也编译
-- allowUnreachableCode = false:不可能执行的代码要不要报错
-- allowUnusedLabels = false:没有用到的 label 要不要报错
-- alwaysStrict = false:按严格模式解析和输出
-- build = false:生产当前项目和依赖项目
-- charset = "utf-8":输入文件的字符集
-- checkJs = false:js文件的错误要不要报
-- declaration = false:生成对应的 .d.ts 文件
-- declarationDir = null:声明文件放在哪里
-- declarationMap = false:生产声明文件 sourcemap
-- diagnostics = false:显示诊断信息
-- disableSizeLimit = false:取消项目大小限制
-- downlevelIteration = false:面向 ES5 和 ES3 时,将 for..of, spread and destructuring 降级
-- emitBOM = false:输入文件编码为带BOM
-- emitDeclarationOnly = false:仅输出声明文件
-- forceConsistentCasingInFileNames = false:强制文件名大小写一致
-- help:帮助
-- inlineSources = false:内联 sourcemap
-- inlineSources = false:内联源码,需要同时设置 inlineSources 和 sourcemap
-- init:初始化一个项目
-- isolatedModules = false:每个文件都是一个独立的模块
-- jsx = "Preserve":jsx处理方式
-- jsxFactory = "React.createElement":jsx 的工厂方法
-- keyofStringsOnly = false:keyof 只使用字符串键解析
-- lib:编译时要使用的库
:ES5: DOM,ES5,ScriptHost
:ES6: DOM,ES6,DOM.Iterable,ScriptHost
-- listEmittedFiles = false:列出生成的文件名
-- listFiles = false:列出生成的文件名
-- locale:错误信息语言
-- module:模块代码怎么生成
:"None", "CommonJS", "AMD", "System", "UMD", "ES6", "ES2015" or "ESNext".
-- watch:盯住输入文件
-- target = "ES3":目标标准
:"ES3" (default), "ES5", "ES6"/"ES2015", "ES2016", "ES2017" or "ESNext".
-- showConfig = false:只显示配置
-- removeComments = fasle:移除注释
-- project:指定配置文件
-- pretty = true:美化输出
--preserveConstEnums = false:保留常量和枚举声明
--noEmit:别输出
--noEmitOnError:出错时别输出
边栏推荐
- msf cs openssl流量加密
- Intermediate web development engineer, interview questions + Notes + project practice
- UCI-HAR数据集的处理
- 202年最新热门收益较高的年金险产品是什么?
- [issue 30] shopee golang development experience
- NFT digital collection app system construction
- my.cnf中 [mysql]与[mysqld] 的区别 引起的binlog启动失败的问题
- 测试cos-html-cache静态缓存插件
- 外观模式--在各种套餐中早就用到啦!
- web开发选型,web开发毕业谁
猜你喜欢
![[第二章 基因和染色体的关系]生物知识概括–高一生物](/img/f0/9f78682798a7874ba176797a6b22ca.png)
[第二章 基因和染色体的关系]生物知识概括–高一生物

An introduction to creating VOC datasets or Yolo datasets using labelimg

Node connects to MySQL database and writes fuzzy query interface

The complete manual of the strongest Flink operator is a good choice for the interview~

Using domestic MCU (national technology n32g031f8s7) to realize pwm+dma control ws2812

2022 | framework for Android interview -- Analysis of the core principles of binder, handler, WMS and AMS!

The tutor transferred me 800 yuan and asked me to simulate a circuit (power supply design)

Method of converting VOC format data set to Yolo format data set

导师转我800块,让我仿真一个电路(电源设计)

SpingBoot+Quartrz生产环境的应用支持分布式、自定义corn、反射执行多任务
随机推荐
Xiao P weekly Vol.08
Vscade -- vscode multi window name is configured as project name
mongoDB 使用
ELK - X-Pack设置用户密码
Is it safe for Xiaobai to open an account directly on the flush?
[file upload vulnerability 06] server file content detection and bypass experiment + image horse production method (based on upload-labs-14 shooting range)
Maximum water container
Modify WordPress management account name plug-in: admin rename extended
my. Binlog startup failure caused by the difference between [mysql] and [mysqld] in CNF
設置默認收貨地址【項目 商城】
Template engine - thymeleaf
Smart sidebar plug-in: Mo widgets
Use pydub to modify the bit rate of the wav file, and an error is reported: c:\programdata\anaconda3\lib\site packages\pydub\utils py:170: RuntimeWarning:
设置默认收货地址【项目 商城】
Définir l'adresse de réception par défaut [Centre commercial du projet]
【Go】Gin源码解读
Iterator mode -- battlefield autumn point
文件excel导出
Dominating set, independent set, covering set
17.5 互斥量的概念、用法、死锁演示与解决详解