Repository navigation
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
yarnto install TS - Run
tsc --build ./tsconfig.json --watch - Wait for the first build to complete
- Go to file
app/actions/index.tsand add this line anywhere in the file, e.g. at the very bottom:console.log('foo') - Save the changes to trigger
tscto 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.
Activity
OliverJAsh commentedon Feb 16, 2021
I tested this again and the rebuild took closer to 1.5 minutes than 2 minutes (TypeScript 4.1.2).
I then upgraded to TypeScript 4.2 RC and repeated the test, and it seemed like there was no improvement.
I don't know how realistic this is but I would like to see rebuilds in the single digits, especially if I'm just adding a
console.logfor debugging purposes like in my example above.sheetalkamat commentedon Apr 30, 2021
This is because the d.ts emit takes long time.. The project in question
C:/temp/unsplash-web/tsconfig.app.jsonseems to spend lot of time in .d.ts emit and you would need to diagnose which type is causing this and help annotate it.Checking with Andrew Casey (@amcasey) to see if our profiling tool can help you with that.
Below shows the timings:
sheetalkamat commentedon Apr 30, 2021
Just chatted with Andrew Casey (@amcasey) offline and here is the link to analyze the trace https://www.npmjs.com/package/@amcasey/ts-analyze-trace but it might not show anything apart from the fact that d.ts is slow.. He will be looking into improving analysing which type causes slow conversion but thats not yet part of it
amcasey commentedon Apr 30, 2021
At present, that tool specifically only outputs information about check time. However, it builds on an underlying tracing system that will show tracing time. Unfortunately, it nearly always just shows that many files took a small amount of time each. I've been working on figuring out how to pinpoint problematic input code.
OliverJAsh commentedon May 4, 2021
Do you expect the changes in 4.3 beta (#43314) will help improve this issue at all?
sheetalkamat commentedon May 4, 2021
Don’t think so .. at least for the scenario you shared .. because at some point you do need .d.ts calculation and that’s where the issue lies
22 remaining items
sahin52 commentedon Nov 26, 2021
Is there an option for not checking the types and just run the app without typechecking?
Edit: I got a new better computer, now it runs much better.
amcasey commentedon Nov 29, 2021
Sahin (@sahin52) If you just want to transpile away the type annotations so you can run, you might want to try something like esbuild.