i18n object is not typed at all in V12
See original GitHub issueAfter updating to v12 and following the instructions here, I get the following TS errors:
const {i18n} = useTranslation();
i18n.language
i18n.changeLanguage
^^^ TS2339: Property 'language' does not exist on type 'i18n'.
error TS2339: Property 'changeLanguage' does not exist on type 'i18n'.
and in the initialize function, as well
i18n.use(initReactI18next).init({
// ...
});
TS2339: Property 'use' does not exist on type 'typeof import("/Users/me/project/src/i18next")'.
But those properties are clearly there when you console.log(i18n)
, along with lots of others. It appears that the i18n object returned by useTranslation has not been typed at all.
How do I set up the i18next.d.ts file so that the i18n
object returned by useTranslation()
is properly typed?
Issue Analytics
- State:
- Created a year ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
TypeScript - react-i18next documentation
In order to fully type the t function, we recursively map all nested keys from your primary locale files or objects. Depending on...
Read more >Angular Internationalization
Internationalization, sometimes referenced as i18n, is the process of designing and preparing your project for use in different locales around the world.
Read more >How to type check i18n dictionaries with TypeScript?
at an example of string interpolation. 1. Key lookup: return type. // returns property value from object O given property path T, otherwise ......
Read more >How To Use ngx-translate with Angular - DigitalOcean
The translation file is a JSON object of key-value pairs, where the key describes the text that is translated, and the value is...
Read more >Next.js 13 Upgrade Guide
Move any beforeInteractive scripts you previously included in _document.js to the root layout file ( app/layout.tsx ). The experimental worker strategy does not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello guys, I have the same issue: Versions I use:
"i18next": "22.0.5"
"react-i18next": "12.0.0"
"typescript": "3.9.10"
Is there any solution?
@pedrodurek I have this problem too.
i18n.ts file
i18next.d.ts file
Both files are under
src
directory in appAnd it complains about this
detailed info:
TS2339: Property 'use' does not exist on type 'typeof import("/Users/tomaskretek/inQool/som.inqool.cz-client/node_modules/.pnpm/i18next@22.0.5/node_modules/i18next/index")'.
TS2339: Property 'isInitialized' does not exist on type 'typeof import("/Users/tomaskretek/inQool/som.inqool.cz-client/node_modules/.pnpm/i18next@22.0.5/node_modules/i18next/index")'.
TS2339: Property 'init' does not exist on type 'typeof import("/Users/tomaskretek/inQool/som.inqool.cz-client/node_modules/.pnpm/i18next@22.0.5/node_modules/i18next/index")'.