当前位置:网站首页>TypeScript的配置文件tsconfig.json
TypeScript的配置文件tsconfig.json
2022-08-03 16:28:00 【SignalFire】
参考网址:TypeScript: Documentation - What is a tsconfig.json (typescriptlang.org)
TypeScript: TSConfig Reference - Docs on every TSConfig option (typescriptlang.org)
一、去掉注释
tsconfig.json初始是这样的
// "removeComments": true,
1、把注释取消掉
"removeComments": true,
2、运行tsc命令
tsc
生成的JS文件中没有注释
"removeComments": true,中true改为false,则不移除注释
3、tsc filename这个命令不会调用配置文件,所以这个命令生成的JS文件是默认配置
二、编译指定文件
在tsconfig.json中增加配置
"include": ["./index.ts"],
"compilerOptions": {
...
}
tsc命令只编译index.ts文件,要增加文件在数组中添加即可
如:
"include": ["./index.ts","./a.tx"],
"compilerOptions": {
...
}
三、不编译指定文件
"exclude": ["./index.ts","./a.tx"],
"compilerOptions": {
...
}
四、显示指定any
"noImplicitThis": true,
Implicit---->adj. 不言明[含蓄]的; 无疑问的,绝对的; 成为一部份的; 内含的;
五、null类型只能赋值给Object
"strictNullChecks": true,
报错:error TS2322: Type 'null' is not assignable to type 'string'
strictNullChecks为true时,null不能赋值给其他类型
六、把指定源目录中的TS文件编译到指定目标目录中
指定TS源目录
"rootDir": "./src", /* Specify the root folder within your source files. */
指定JS目标目录
"outDir": "./build", /* Specify an output folder for all emitted files. */
七、只编译新内容,渐进式编译/增量式编译
"incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
设置为true后运行tsc会产生一个文件tsconfig.tsbuildinfo,里面记录了上一次编译的具体信息,下一次编译时会对照这个文件,只编译新内容
八、允许编译JS文件
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
设置为true后,源目录中的JS文件也会被编译
九、检查JS文件的语法
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
十、编译时生成.map文件
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
十一、从未使用的局部变量报错
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
十二、从未使用的函数参数报错
"noUnusedParameters": true,/* Raise an error when a function parameter isn't read. */
边栏推荐
- DataGrip数据仓库工具
- 高薪程序员&面试题精讲系列132之微服务之间如何进行通信?服务熔断是怎么回事?你熟悉Hystrix吗?
- mysql delete execution error: You can't specify target table 'doctor_info' for update in FROM clause
- 想进阿里?先来搞懂一下分布式事务
- protobuf 中数据编码规则
- How to analyze the weekly activity rate?
- [Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 01
- 2021年数据泄露成本报告解读
- TCP 可靠吗?为什么?
- 如何在 DataWorks 中 写SQL语句监控数据的变化到达一定的值 进行提示
猜你喜欢
如何设计大电流九线导电滑环
可复现、开放科研、跨学科合作:数据驱动下的科研趋势及应用方案
为什么我强烈推荐使用智能化async?
使用uniapp 封装一个request 请求
华为、联想、北汽等入选工信部“企业数字化转型和安全能力提升”首批实训基地
QT QT 】 【 to have developed a good program for packaging into a dynamic library
C专家编程 第1章 C:穿越时空的迷雾 1.9 阅读ANSI C标准,寻找乐趣和裨益
Not to be ignored!Features and advantages of outdoor LED display
不可忽略!户外LED显示屏的特点及优势
一文看懂推荐系统:召回02:Swing 模型,和itemCF很相似,区别在于计算相似度的方法不一样
随机推荐
How much do you know about the intelligent operation and maintenance service of data warehouse based on DMS?
Kubernetes 笔记 / 入门 / 生产环境 / 容器运行时
To participate in sweepstakes, incoming new programmers magazine welfare!
C专家编程 第1章 C:穿越时空的迷雾 1.10 “安静的改变”究竟有多少安静
Spark entry learning-2
SQL中对 datetime 类型操作
使用Stream多年,collect还有这些“骚操作”?
smp,numa和mpp体系结构总结
Tolstoy: There are only two misfortunes in life
Selective Search学习笔记
面了个腾讯35k出来的,他让我见识到什么叫精通MySQL调优
建造者模式/生成器模式
黄致绮 荣获第六季完美童模全球总决赛 全国总冠军
leetcode:189. 轮转数组
机器人开发--Universal Scene Description(USD)
To add digital wings to education, NetEase Yunxin released the overall solution of "Internet + Education"
"Avnet Embedded Weekly" Issue 276: 2022.07.25--2022.07.31
socket快速理解
EasyExcel实现动态列解析和存表
node连接mongoose数据库流程