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
Typescript compiler incredibly slow with larger number of language resource keys with version >=22 #1857
Comments
One more thing: I am not sure what is a reasonable number of text resources one can use before Typescript slows down considerably. I guess it could do so with already a few thousands. Was this benchmarked/tested already? |
To answer my own question, I found https://github.com/pedrodurek/i18n-type-tests :). Here some numbers from our project: language-resources contains about 5000 resource keys (mostly static keys) timings:
Seems performance issues escalate rather quickly after the number of keys reaches 10000. |
Thanks @gunters63 for reporting that. |
Hi @pedrodurek, not sure if related to this, I would say it is, but I am too finding some issues in the eslint checking after updating Thank you! |
I have some ideas to reduce the compilation time, and will be working on it in the next days |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
With the update to version 22 we had lots of Typescript errors in our code base (see also #1852), so we followed the recommended approach to include a declaration file as described in https://www.i18next.com/overview/typescript
However, if we follow this, the Typescript compiler gets incredibly slow, instead of a couple of seconds it now takes minutes to type-check our UI project. As we also use ESlint (with Typescript) to automatically fix issues when saving VS-Code got very laggy too.
I guess this has something to do with the quite large number of language resources, we have over 23000 text resources split over three files. Yes, we have our reasons to have so many and most of the language resource keys are dynamically evaluated at runtime.
I suggest to document a workaround for such use-cases. I changed the new type declarations file like this:
With this change, Typescript is as fast as before.
Basically, this reverts the return type of the t() function to the old behaviour, always returning a string.
One could handle this separately for each name space. Maybe we do this too because by far the most language resources with dynamically evaluated keys live only in one name space.
The text was updated successfully, but these errors were encountered: