You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have working setup like that. But the problem is when I try to introduce template literals.
Let's say I have type: type MyType = 'part1' | 'part2' | 'part3';
And I want to get the translation like so:
const part: Part = 'part1'; const {t} = useTranslation('description.${part}'); //Error
This will give me TS error.
Only if single raw string is used TS will understand that this is ok.
The text was updated successfully, but these errors were encountered:
Hey @KestasVenslauskas, this a typescript limitation which is going to be handled on typescript 4.2.
In the meantime, you can solve this problem by asserting your template string as const. Like this:
Here you have an example which works fine:
https://github.com/i18next/react-i18next/blob/master/example/react-typescript4.1/no-namespaces/src/App.tsx
I have working setup like that. But the problem is when I try to introduce template literals.
Let's say I have type:
type MyType = 'part1' | 'part2' | 'part3';
And I want to get the translation like so:
const part: Part = 'part1'; const {t} = useTranslation('description.${part}'); //Error
This will give me TS error.
Only if single raw string is used TS will understand that this is ok.
The text was updated successfully, but these errors were encountered: