是否可以通过tsc转换typescript来禁用类型检查以加快转换?

k0p*_*kus 5 performance configuration typescript tsc

即使只有一个文件实际发生了变化,TypeScript也会在转换时检查整个代码库.对于小型项目,这很好,但是自从我们的代码库增长以来,需要相当长的时间.

在开发过程中,我希望我的单元测试能够快速响应.单元测试应该尽快运行.

不幸的是,我必须等待每次运行大约10-15秒才能进行单元测试甚至开始,因为tsc需要花费很长时间才能完成,并且在那个时间内花费60%-80%用于检查.

这些示例运行只是从一个文件中删除和添加换行符:

yarn tsc v0.27.5
$ "/home/philipp/fancyProject/node_modules/.bin/tsc" "--watch" "--diagnostics"
Files:           511
Lines:        260611
Nodes:        898141
Identifiers:  323004
Symbols:      863060
Types:        302553
Memory used: 704680K
I/O read:      0.17s
I/O write:     0.09s
Parse time:    2.61s
Bind time:     0.95s
Check time:    7.65s
Emit time:     1.45s
Total time:   12.65s
00:35:34 - Compilation complete. Watching for file changes.


00:41:58 - File change detected. Starting incremental compilation...


Files:            511
Lines:         260612
Nodes:         898141
Identifiers:   323004
Symbols:       863060
Types:         302553
Memory used: 1085950K
I/O read:       0.00s
I/O write:      0.04s
Parse time:     0.68s
Bind time:      0.00s
Check time:    12.65s
Emit time:      1.36s
Total time:    14.69s
00:42:13 - Compilation complete. Watching for file changes.


00:42:17 - File change detected. Starting incremental compilation...


Files:            511
Lines:         260611
Nodes:         898141
Identifiers:   323004
Symbols:       863060
Types:         302553
Memory used: 1106446K
I/O read:       0.00s
I/O write:      0.12s
Parse time:     0.32s
Bind time:      0.01s
Check time:     9.28s
Emit time:      0.89s
Total time:    10.50s
00:42:27 - Compilation complete. Watching for file changes.
Run Code Online (Sandbox Code Playgroud)

我想知道是否有办法告诉打字稿:

只需将所有内容都视为正常,然后尽快将JavaScript转储到磁盘上.

我想首先确保我的单元测试通过,以便有一个快速的反馈循环.

由于我的IDE负责处理我目前正在处理的文件中的类型检查,因此我很少在检查转换时遇到错误.如果有一个大问题,我的单元测试应该抓住它们.

在构建项目时,我会使用经典的tsc和支票.正如我所说,这仅用于开发并具有快速反馈循环.

les*_*syk 0

  1. 开始使用 WebPack
  2. 添加很棒的打字稿加载器
  3. transpileOnly在设置中设置为true

您还可以更改其他参数,这可以提高速度:ignoreDiagnosticsforceIsolatedModules等。