我想使用 TypeScript 的 --incremental
模式以使其在重复运行时更快。然而我的 tsconfig.json
套"noEmit": true
因为我目前只使用 TypeScript 进行类型检查而不是代码生成。
如果我运行 tsc --incremental --outDir ~/tmp/typescript --noEmit
它似乎没有输出 tsconfig.tsbuildinfo
文件,因此实际上不会在重复运行时进行增量编译。
我想我实际上可以启用发射并运行 tsc --incremental --outDir ~/tmp/typescript --noEmit false
但随后它不仅生成 tsconfig.tsbuildinfo
还有一堆我不需要的 JS 文件,这并不理想。
有什么办法可以运行tsc --incremental --noEmit
,其实是增量编译,只生成tsconfig.tsbuildinfo
增量编译需要文件吗?
最佳答案
更新:incremental
的组合和 noEmit
终于可以使用 TS 4.0 .
到目前为止,不幸的是没有办法拥有incremental
使用 noEmit
构建选项启用更快的类型检查运行。例如。这将很有用,当有一个单独的 typescript 编译步骤时 @babel/preset-typescript
或类似。
开发人员关于您的问题的声明:
The problem here is that incremental is on by default if composite is on, so this is an actual risky change because it's going to mean new build artifacts in unexpected places for people using --noEmit today.
If the build info file path is specified manually, then writing it out does seem OK
所以希望有机会在 future 的版本中实现这样的功能。您可以关注 here用于进度跟踪。
关于typescript - 使用 --noEmit 时使用 TypeScript 进行增量编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57078953/