当前位置:网站首页>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. */
边栏推荐
- 一文看懂推荐系统:概要02:推荐系统的链路,从召回粗排,到精排,到重排,最终推荐展示给用户
- MySQL窗口函数
- Detailed explanation of ReentrantReadWriteLock
- AI+BI+Visualization, Deep Analysis of Sugar BI Architecture
- 使用uniapp 封装一个request 请求
- 简易网络传输方法
- 【无标题】
- Leetcode76. Minimal Covering Substring
- 新版本 MaxCompute 的SQL 中支持的 EXTRACT 函数有什么作用?
- Understand the recommendation system in one article: Outline 02: The link of the recommendation system, from recalling rough sorting, to fine sorting, to rearranging, and finally showing the recommend
猜你喜欢

一文看懂推荐系统:概要02:推荐系统的链路,从召回粗排,到精排,到重排,最终推荐展示给用户

Detailed ReentrantLock

一文看懂推荐系统:召回03:基于用户的协同过滤(UserCF),要计算用户之间的相似度

【深度学习】今日bug(8月2)

组件通信-父传子组件通信

Not to be ignored!Features and advantages of outdoor LED display

使用 PowerShell 将 Windows 转发事件导入 SQL Server

使用Stream多年,collect还有这些“骚操作”?

SQL中对 datetime 类型操作

C专家编程 第1章 C:穿越时空的迷雾 1.6 它很棒,但它符合标准吗
随机推荐
ArkUI如何适配横竖屏
实时渲染流程操作复杂吗,如何实现?
虹科分享 | 如何测试与验证复杂的FPGA设计(3)——硬件测试
我写了个”不贪吃蛇“小游戏
83. Remove Duplicates from Sorted List
"Avnet Embedded Weekly" Issue 276: 2022.07.25--2022.07.31
mysql delete execution error: You can't specify target table 'doctor_info' for update in FROM clause
2年开发经验去面试,吊打面试官,即将面试的程序员这些笔记建议复习
一文看懂推荐系统:召回03:基于用户的协同过滤(UserCF),要计算用户之间的相似度
socket快速理解
使用uniapp 封装一个request 请求
To add digital wings to education, NetEase Yunxin released the overall solution of "Internet + Education"
正向代理与反向代理
Yuan xiaolin: Volvo focus on travel security, and put it perfectly
vector类
C专家编程 第3章 分析C语言的声明 3.3 优先级规则
SwinIR实战:详细记录SwinIR的训练过程
《社会企业开展应聘文职人员培训规范》团体标准在新华书店上架
DAYU200 OpenHarmony标准系统HDMI全屏显示
Auto Scaling 弹性伸缩(运维释放人力)