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
Add documentation for the new breaking change in TS #1852
Comments
@pedrodurek @rosskevin it starts 😉 |
yes, seeing the same on this.
|
I really wonder why this is done? This will be a tremendous change. What is the benefit? |
relevant PRs: first version of ts docs: https://www.i18next.com/overview/typescript other maybe related stuff: @pedrodurek and/or @rosskevin will hopefully try to answer asap... |
i18next has been the most stable api for so long of all the packages I use - I really hope that this change is making life better somehow. |
JS api is still the same... only the TS interface did receive a major rewrite because of many "wishes" by the community... nevertheless it's a semver major bump. Please be patient and give the opportunity to @pedrodurek and @rosskevin to explain this TS change. |
We simply moved the type enhancements from |
I was waiting to release both versions to create some examples of use. Later today, I'll put a PR up with some examples. |
Well for example, I am using Material UI, and some props expect things to be In general, if you are using any 3rd party library and their props expect strings, this will be a problem. |
yep, the first bitten part was:
ariaLabel?: string | undefined; |
I am also fiding in more harmless invocations:
|
The PR that I just opened should fix the problem, but I really recommend to follow the steps here https://www.i18next.com/overview/typescript, to get the best of |
@httpete and @DavidArmendariz - in the future, the best way to convey your case would be to PR a minimal breaking test - e.g. check out https://github.com/i18next/i18next/blob/master/test/typescript/t.test.ts#L39 If it is react related, check out something like https://github.com/i18next/react-i18next/blob/master/test/typescript/useTranslation.test.tsx and PR one there. For our codebase update (which included mui 4) on a large codebase, I had only three or so By PR'ing minimal breaking tests, it allows us to not only fix these now, but make sure we don't have regressions later. Thanks for taking time to research the issue and trying out this major release. |
What I am finding here that makes all the problems go away is to:
|
I also found @rosskevin , it found some legit bad usages in our codebase as well. Thank you for keeping our ts game tight. We recently did this with Zustand 4 as well, it seems that as TS gets better and developer understanding how to leverage it improves, it ripples through everything. This is good. |
@rosskevin @pedrodurek @adrai Looks like the new version (22.0.3) re-introduced the same problem. |
@DavidArmendariz I haven't seen a problem today. I did see that my casts needed to be updated, as they were also incorrect based on the latest e.g. I suggest you open a new issue, link to this, and provide a test case. Or if it is react related, do so there. Breaking tests in PRs are very valuable and prevent regressions. |
Documentation issue
Yesterday, there was a breaking change where now the
t
function is not returning a string anymore. It is returning aDefaultTFuncReturn
. This is breaking a lot of things in my React app because I used to say thatt
would just return a string. In fact, it still does so when you use variables inside the string like thisi18next.t('{{var}} something', { var })
.Motivation
I have researched and there is no documentation on why this change was made or how it would impact existing projects.
The text was updated successfully, but these errors were encountered: