2017-08-29 80 views
5

打字稿檢查上transpiling整個代碼庫,即使只有一個文件實際上已經改變了。對於小型項目來說,這很好,但是由於我們的代碼庫增長,需要相當長的時間。當通過tsc傳輸打字稿來加速轉譯時,是否可以禁用類型檢查?

在開發過程中,我想我的單元測試,快速的響應時間。單元測試應該儘快運行。

不幸的是,我必須等待,在每次運行約10-15秒爲單位測試甚至開始爲在tsc需要很長的時間來transpile,和當時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. 

我不知道是否有辦法告訴打字稿:

只是把一切都爲OK,只是轉儲JavaScript儘可能快地到磁盤。

我要確保第一是我的單元測試通過纔能有一個快速的反饋迴路。

而且因爲我的IDE已經花費我目前正在對文件中的護理類型的檢查,我很少在transpiling的檢查有錯誤呢。如果有一個大問題,我的單元測試應該抓住它們。

構建項目時,我只想用經典的TSC與檢查。正如我所說,這只是爲了發展,並有一個快速的反饋循環。

+0

Webpack與[ts-loader](https://github.com/TypeStrong/ts-loader)重新編譯只依賴於更改的文件和文件更改文件。 [這裏](https://github.com/Microsoft/TypeScript-Vue-Starter#typescript-vue-starter)你可以找到樣本配置。 –

+0

@AlekseyL。您可以請將您的評論擴展爲一個答案,更詳細地介紹如何使用ts-loader? – k0pernikus

回答

0
  1. 開始使用的WebPack
  2. 添加awesome-typescript-loader
  3. 設置transpileOnly在設置true

你也可以改變其他paramers,它可以提高速度:ignoreDiagnosticsforceIsolatedModules

+0

可否請您添加更深入的必要配置更改版本? (我也已經安裝了webpack,對於ts文件,並且很難找到添加什麼以及如何影響內容。 – k0pernikus

+0

您不明白WebPack或awesome-typescript-loader文檔的哪一部分? – lesyk

相關問題