Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize tsc start time in watch mode for big projects #236

Merged
merged 1 commit into from Jan 12, 2022

Conversation

11bit
Copy link
Contributor

@11bit 11bit commented Aug 22, 2020

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:

  • Resolved #XXX

Checklist

  • I have read CONTRIBUTING.md
  • I have linked all related issues above
  • I have rebased my branch

For bugfixes:

  • I have added at least one unit test to confirm the bug have been fixed
  • I have checked and updated TOC and API Docs when necessary

For new features:

  • I have added entry in TOC and API Docs
  • I have added a short example in API Docs to demonstrate new usage
  • I have added type unit tests with dts-jest
  • I have added runtime unit tests with dts-jest

@piotrwitek
Copy link
Owner

Thanks, it seems to make sense. Thanks for investigating this!

@piotrwitek piotrwitek merged commit 8596699 into piotrwitek:master Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants