-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Make typescript autocomplete aware of contextSeparator #1334
Make typescript autocomplete aware of contextSeparator #1334
Conversation
Thanks @JCQuintas for that! I may take a few days to review it because I'll need to measure and test how much in terms of time complexity has increased. We're recursively mapping all keys & return types and any extra complexity might affect compilation time (big applications mostly). |
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. |
Is there any way I can help testing this out? |
Hey @JCQuintas, sorry about the delay, these last couple of weeks have been challenging for me, I'll finish reviewing it today! |
@pedrodurek no worries. I'm in no hurry 😉 |
Hey @JCQuintas, I finally finished all tests, but unfortunately, I don't have great news. Compilation time got ~10x slower than before (retrieve keys and return type) with the proposed changes 😢 . You can clone my test project and compare it yourself. Mac specs Typescript was taking ~2.3 seconds to infer and retrieve the keys (thousands of keys), and that number increased to |
@pedrodurek that is odd, I went to try it on my machine and results differed a lot from yours, and are actually on par with a previous test I did where compilation time increased about 10%. Maybe I'm doing something wrong?
my steps were
I also tried adding some keys with actual Can you check this out? My specs are as follows
|
Hey @JCQuintas, sorry I should have clarified a lit bit more. The actual build time didn't suffer much (around 10%, as you explained), the problem lies in the TS Server from VScode (or similar) when inferring (autocompleting/ts check) keys/return type for you. In order to test it, you need to enable the Ts Server log, you can find more info about that here. Screen.Recording.2021-07-20.at.4.49.42.PM.mov |
@pedrodurek AH! I see, yeah that is an issue. I don't have any immediate fix for that, and I suppose it would require some amount of time to nail out the issues and try to simplify the inference, if at all possible. Should I close this PR then? |
I'd keep it open until we find a way to improve that. What do you think @adrai ? Thanks @JCQuintas btw! 🙌 |
@JCQuintas should be addressed with i18next v23.4.0 via i18next/i18next#2006 |
This makes the
react-i18next
types aware of thecontextSeparator
, we might want to make it possible to change it later, similar to how we allow changing thedefaultNS
, but for now it should be simple to fix and user's issue.How it works: keys that end in
_${string}
will be added with and without the ending to the type auto-completion.eg:
fixes #1333
Checklist
npm run test