Type instantiation is excessively deep and possibly infinite.
See original GitHub issueš Bug Report
Typescript generate this warning when Iām trying to setting up library.
Type instantiation is excessively deep and possibly infinite.
Iāve research around and please do note that:
- I had completely followed setup instruction on the official page to create react-i18next.d.ts file.
- I had no empty array in my translation files
- The warning disappear when I remove react-i18next.d.ts file.
To Reproduce
const resources = { ... } as const;
export const defaultNS = 'translation'
i18n
.use(initReactI18next)
.init({
resources,
lng: language,
fallbackLng: 'en',
debug: false,
defaultNS,
supportedLngs: ['cn', 'en'],
})
export default i18n;
And I got the warning here (for some translation, not every translation)
label={t('common:button.confirm')}
=> Type instantiation is excessively deep and possibly infinite.ts(2589)
Expected behavior
Expect not to show the warning.
Your Environment
- runtime version: nodeās v14.15.5
- i18next version:^20.6.1
- react-i18next: ^11.12.0
- typescript: ~4.0.0
- os: Mac
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:14 (6 by maintainers)
Top Results From Across the Web
āType instantiation is excessively deep and possibly infinite ...
Actual behavior: I'm getting this: Type instantiation is excessively deep and possibly infinite.ts(2589).
Read more >how to ignore "Type instantiation is excessively deep and ...
Type instantiation is excessively deep and possibly infinite. ts(2589). It happens when TS decides that types become too complex to computeĀ ...
Read more >TypeScript. Type instantiation is excessively deep and ...
Type instantiation is excessively deep and possibly infinite. How to fix. I've just started a migration to TypeScript. I see many unknown and...
Read more >Type instantiation is excessively deep and possibly infinite ...
Getting `Type instantiation is excessively deep and possibly infinite` errors whenever I pass MongoClient as a parameter in my code afterĀ ...
Read more >TypeScript - i18next documentation
Type error - excessively deep and possibly infinite ... If you face this issue whenever calling the t function: TS2589: Type instantiation is...
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
@pedrodurek After weeks of investigation, I found the problem.
Firstly, the mistake comes from my side when I forgot to
export const resources = {} as const
. This will lead toType instantiation is excessively deep and possibly infinite
Secondly, When I
export
it. New issue comes with āNo matching overloadā. And I found that your document and your example are not aligned together.Document show this code https://react.i18next.com/latest/typescript
But your example show this code https://github.com/i18next/react-i18next/blob/master/example/react-typescript4.1/namespaces/%40types/react-i18next/index.d.ts
What show in example is correct. I hope you should update your instruction on official document
Hey @innonguyen, thanks for letting me know, Iāll update the code example. Even though the old way is deprecated, both approaches should be working.