question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
innonguyencommented, Oct 21, 2021

@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 to Type 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 Screen Shot 2021-10-21 at 22 26 58

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

Screen Shot 2021-10-21 at 22 26 29

What show in example is correct. I hope you should update your instruction on official document

0reactions
pedrodurekcommented, Oct 21, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found