Optimize tsc start time in watch mode for big projects #236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Hi!
I have a problem in a big project that uses typesafe-actions.
tsc
in watch mode starts many times slower than a standalone check.After some googling and debugging I think I found the root cause of the slow down.
Looks like tsc in watch mode generates temporary declaration (d.ts) files for incremental checks. And it turned out that generated typings for reducers are really big so that tsc spends a lot of time producing these temp files when starting.
The declaration files are big because of the recursive types that typescript doesn't handle well. For instance, this is what tsc produces for
benchmarks/10-actions.ts
from this repo - https://gist.github.com/11bit/ae4a19748c0ffaec44db4f2890e030d8. Looks like typescript tries to unfold them or something.The workaround to optimize it is to expose these internal recursive types HandleActionChainApi and HandleTypeChainApi, so that tsc will be able to use them as is.
There is a discussion about a similar issue in typescript repo microsoft/TypeScript#34119
Related issues:
Checklist
For bugfixes:
For new features:
dts-jest
dts-jest