-
-
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
Linting of TFunction fails since the last update #1212
Comments
@pedrodurek can you have a look at this? |
Same here, was looking into failing builds for the past 30 mins. This only seems to be the case in the 4.1 typings, 4.0.x is fine. At least it helped me find out our CI uses a different TS version compared to my local environment 😅 Edit: Can confirm our CI works fine with 4.0.x again, until this issue is resolved. |
sure 👀 @adrai |
Same here. |
Hey guys, I'm still investigating it, but I managed to simulate the error using CRA. When I performed the tests for the first time, CRA wasn't supporting typescript 4.1 properly (facebook/create-react-app#9960), so I used pure webpack (https://github.com/pedrodurek/i18n-type-tests), which works perfectly. I'll let you guys know as soon as I sort that out. @adrai in the meantime, what do you suggest? |
I'm not a TS user... |
If any help is needed, you know where to find me 🐅 🎉 😃 |
@pedrodurek I'm using NextJS. They do support TS 4.1. |
Oh! I took a look at your example and noticed that the error does NOT occur when you pass a namespace to |
Hey guys, I managed to fix the issue. I'm gonna add two examples (with and without namespaces) under |
It should be fixed now |
Hi, i'm still getting this error
Please advise |
Hey @vtrphan, since it's not related to this issue, I'd advice you to open another one and provide more info. But in a nutshell, I can see that you're passing an object as key to the |
@pedrodurek Yes i'm using the approach/setup from react-boilerplate |
That's weird because even in the v11.7, it was only accepting |
@vtrphan I may be wrong, but looks like you are not using the i18n doing this |
@adrianolsk Hi, it is this approach/setup that i'm following: |
The PR fixed my issue. Thanks! |
Has anyone run into the situation where you're swapping out the "base" of a key? I'm trying to use TypeScript template strings and this used to work but now requires extra TypeScript casting: Before: const i18nBase = isSubmitted ? 'path.to.something.resubmit' : 'path.to.something.submit'
const title = t(`${i18nBase}.title`) Interpreting the string in this manor fails to compile with errors like const i18nBase = isSubmitted ? 'path.to.something.resubmit' : 'path.to.something.submit'
const title = t(`${i18nBase}.title` as const) but it feels like something that I shouldn't have to do. Is there a better way to do this? We exercise this pattern quite frequently in our codebase, especially for re-usable components which might be in different states and I was hoping to avoid having to rewrite them all. Thanks! |
Hey @joelpoloney, I believe I answered your question here: #1193 (comment) |
💥 Regression Report
Linting of
TFunction
fails since the last update. Thet
function should accept itskey
parameter to bestring | string []
. However, it seems to expect to benever
.K
seems to resolve tonever
atreact-i18next/src/ts4.1/index.d.ts
Line 91 in a4aaf65
Last working version
Worked up to version: 11.7.4
Stopped working in version: 11.8.0
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect to not have Argument of type 'string' is not assignable to parameter of type 'never'.ts(2769) at line 6 for
t('hello')
Full error:
Your Environment
The text was updated successfully, but these errors were encountered: