【问题标题】:Long TypeScript compilation time?TypeScript 编译时间长?
【发布时间】:2017-08-14 23:36:54
【问题描述】:

我正在使用 TypeScript 2.2.1,并且在执行 tsc 时遇到了很长的编译时间,所以我添加了 --diagnostics 希望它可以给我更多信息。但是,我注意到报告的“总时间”与我观察到的时间不准确。

例如,当我跑步时

$ date && tsc  --diagnostics && date
Wed, Mar 22, 2017  1:21:41 PM
Files:          200
Lines:        25865
Nodes:        91671
Identifiers:  30796
Symbols:      32727
Types:         8447
Memory used: 64572K
I/O read:     0.07s
I/O write:    0.02s
Parse time:   1.17s
Bind time:    0.30s
Check time:   0.97s
Emit time:    0.16s
Total time:   2.61s
Wed, Mar 22, 2017  1:22:52 PM

由于开始时间是下午 1:21:41,结束时间是下午 1:22:52,我希望 tsc 中报告的总时间约为 1 分钟,但它显示为 2.61 秒不正确。

有没有更好的方法来跟踪 tsc 中的编译时间?

【问题讨论】:

  • 写一个node模块让它调用tsc编译器并将其注册为package.json中的脚本,然后以npm run tsc运行它

标签: node.js typescript npm tsc


【解决方案1】:

我希望在 tsc 中报告的总时间约为 1 分钟,但它显示为 2.61 秒,这是不正确的。

根据 tsc 报告的时间,我怀疑它与 tsc 无关,而只是 nodejs 启动时间。

尝试time node somesimplefile.js 并修复您的节点安装(重新安装/更新),如果它花费的时间太长。

【讨论】:

    【解决方案2】:

    不知道为什么,但我们发现编译时间长是由于 tsconfig.json 中的这一行

    "extends": "../tsconfig",
    

    去掉后,编译时间长的问题解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-25
      • 2022-11-14
      • 2021-09-09
      • 2017-05-25
      • 2019-09-01
      • 2011-08-29
      相关资源
      最近更新 更多