当前位置:网站首页>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. */
边栏推荐
- Hannah荣获第六季完美童模全球总决赛全球人气总冠军
- 一文看懂推荐系统:召回02:Swing 模型,和itemCF很相似,区别在于计算相似度的方法不一样
- 罗克韦尔AB PLC RSLogix5000中创建新项目、任务、程序和例程的具体方法和步骤
- How much do you know about the intelligent operation and maintenance service of data warehouse based on DMS?
- 如何在 DataWorks 中 写SQL语句监控数据的变化到达一定的值 进行提示
- SwinIR实战:如何使用SwinIR和预训练模型实现图片的超分
- C专家编程 第1章 C:穿越时空的迷雾 1.8 ANSI C标准的结构
- 兄弟组件通信context
- C语言02、语句、函数
- uniapp隐藏导航栏和横屏显示设置
猜你喜欢

为什么我强烈推荐使用智能化async?

Introduction to spark learning - 1

我在滴滴做开源

Interpretation of the 2021 Cost of Data Breach Report

I am doing open source in Didi
![[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 02](/img/45/96af4ca21329964808a4c8f2b8272c.png)
[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 02

B站回应HR称核心用户是Loser;微博回应宕机原因;Go 1.19 正式发布|极客头条

#夏日挑战赛# HarmonyOS 实现一个绘画板

Detailed ReentrantLock

组件通信--下拉菜单案例
随机推荐
面试不再被吊打!这才是Redis分布式锁的七种方案的正确打开方式
STM32 GPIO LED and buzzer implementation [Day 4]
Detailed explanation of ReentrantReadWriteLock
【带你了解SDN和网络虚拟化】
leetcode-268.丢失的数字
如何使用MATLAB绘制极坐标堆叠柱状图
Hannah荣获第六季完美童模全球总决赛全球人气总冠军
To add digital wings to education, NetEase Yunxin released the overall solution of "Internet + Education"
[Unity Getting Started Plan] Basic Concepts (8) - Tile Map TileMap 02
DAYU200 OpenHarmony标准系统HDMI全屏显示
Leetcode76. 最小覆盖子串
【翻译】关于扩容一个百万级别用户系统的六个课程
大佬们。使用flink-cdc-sqlserver 2.2.0 版本读取sqlserver2008R
"Avnet Embedded Weekly" Issue 276: 2022.07.25--2022.07.31
#夏日挑战赛#【FFH】OpenHarmony设备开发基础(四)启动流程
Kubernetes 笔记 / 入门 / 生产环境 / 用部署工具安装 Kubernetes / 用 kubeadm 启动集群 / 安装 kubeadm
smp,numa和mpp体系结构总结
C专家编程 第3章 分析C语言的声明 3.8 理解所有分析过程的代码段
【AppCube】零代码小课堂开课啦
高效的组织信息共享知识库是一种宝贵的资源