Description
Bug Report
π Search Terms
performance, tsc, watch, build, rebuild, declaration, emit, incremental
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about performance.
β― Playground Link
Unfortunately I cannot provide a reduced test case as I can only reproduce this on our very large project.
π» Code
TypeScript 4.1.2
- Clone and checkout https://github.com/unsplash/unsplash-web/tree/typescript-watch-issue, branch
typescript-watch-issue
. This is a private repository but I believe some members of the TS team already have access from debugging previous issues. If you don't have access, please send me your email address so I can provide access (TS team members only). - Run
yarn
to install TS - Run
tsc --build ./tsconfig.json --watch
- Wait for the first build to complete
- Go to file
app/actions/index.ts
and add this line anywhere in the file, e.g. at the very bottom:console.log('foo')
- Save the changes to trigger
tsc
to rebuild
π Actual behavior
The rebuild takes too long. On my machine it takes over 2 minutes.
π Expected behavior
I expected the rebuild to be very fast, because we're using all of the performance optimisations at our disposal: e.g. incremental
and project references.
One thing I noticed that might be helpful for debugging: the generated declaration file for app/actions/index.ts
βtarget-tsc-build/app/actions/index.d.ts
βis fairly small after the first build (after step 4) but then for some reason it is significantly larger after the second build (after step 6). I don't understand why these declarations would change after such a simple change.
Subsequent changes to this file do not suffer from this problem, e.g. if we remove the console.log('foo')
line that was added in step 5 and then save the changes to trigger another rebuild, the rebuild is very fast.