-
-
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
Type instantiation is excessively deep and possibly infinite.ts(2589) #1601
Comments
Update: I've tried all latest release versions and the problem starts occurring from |
I can confirm this problem occurs for me as well on the following configuration:
|
@marakim it's definitely something with |
The same issue for me after upgrading |
Hey @xdebbie, jugging by what you shared, it seems in the The others who are facing the same issue, please take a look at our examples here or provide minimal reproducible example. It's very likely that you miss a step in your configuration. |
+1 {
"i18next": "^22.4.9",
"react-i18next": "^12.1.4"
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
To solve that, is just create a @type file with typeof resources. `import { resources, defaultNS } from "translation/config"; declare module "i18next" { |
I still have the same issue despite having tried many solutions...
Path: import "i18next";
import type common from "@public/locales/en/common.json";
declare module "i18next"
{
interface CustomTypeOptions
{
defaultNS: "common";
resources: {
common: typeof common;
};
returnNull: false;
returnEmptyString: false;
}
} Path: // @ts-check
/**
* @type {import("next-i18next").UserConfig}
*/
module.exports = {
debug: process.env.NODE_ENV === "development",
reloadOnPrerender: process.env.NODE_ENV === "development",
localePath: typeof window === "undefined" ? require( "path" ).resolve( "./public/locales" ) : "/locales",
18n: {
defaultLocale: "en",
locales: [ "en", "fr" ],
},
}; |
I had also some errors* after upgrading the i18next dependencies, but I was able to solve them all by declaring two modules as below:
import { resources, defaultNS } from './i18n';
declare module 'react-i18next' {
interface CustomTypeOptions {
defaultNS: typeof defaultNS;
resources: typeof resources['en'];
}
}
declare module 'i18next' {
interface CustomTypeOptions {
returnNull: false;
}
} I also added *i.e.
|
Thank you @GoldenSoju the two modules method worked for me too. The first module solved: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am also facing similar issues. The solution from @GoldenSoju seems to remove the typings completely, with that configuration I can pass whatever to
to |
I can also confirm that, version prior to 11.18.6 solves all my typing issues. |
@FlorianLeChat did you only downgrade Am using @pedrodurek any updates on merging i18next/i18next#1911? 😊 |
I downgraded |
Indeed, thanks! Using |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue is still relevant. |
Is it really possible to solve this problem? I think there is some kind of limitation in TypeScripts, because I got this problem when my number of namespaces reached 100. I have to use a JS script to parse the locale files to generate a TS file with keys. I think you should note this problem in the documentation because a lot of people rely on typing. |
@pedrodurek is on it here: i18next/i18next#1911 |
I finally just ignored it. with |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm still having this issue...
Although after digging through my code a bit, I noticed some components have the issue and some simply don't, and sometimes the issue is only displayed when using an array instead of a string... My config: import "i18next";
import common from "../../public/locales/en/common.json";
import auth from "../../public/locales/en/auth.json";
import dashboard from "../../public/locales/en/dashboard.json";
import profile from "../../public/locales/en/profile.json";
import pods from "../../public/locales/en/pods.json";
import kyc from "../../public/locales/en/kyc.json";
import marketplace from "../../public/locales/en/marketplace.json";
import passport from "../../public/locales/en/passport.json";
import proposals from "../../public/locales/en/proposals.json";
import { UseTranslation } from "next-i18next";
import { Namespace } from "i18next";
declare module "i18next" {
interface CustomTypeOptions {
defaultNS: "common";
resources: {
common: typeof common;
auth: typeof auth;
dashboard: typeof dashboard;
profile: typeof profile;
pods: typeof pods;
kyc: typeof kyc;
marketplace: typeof marketpace;
passport: typeof passport;
proposals: typeof proposals;
};
}
} Example of array vs string args:
|
The next major version of i18next should fix that |
Please try with i18next v23.0.1 and react-i18next v13.0.0 |
All my issues seem to be fixed. Thanks a lot! |
It didn't solve my issue. @adrai is there a specific typescript version I should use? I'm using ˆ5.0.4 |
@ste7en v4 and v5 should work.... can you please provide a minimal reproducible example? |
@adrai thanks for the willingness. I was preparing a monorepo example with Nx (used in my real workspace) and while waiting for it to complete I tried adding |
I'm trying to embed i18next type definitions within our application but I have mutliple issues. The main issue is I also have the following issues:
Here's my minimal reproducible example that is based on |
@sebastien-comeau using the same keys with the t function works, right? |
@adrai: Using a good key with |
regarding intellisense: microsoft/TypeScript#54708 |
Hey @sebastien-comeau, this will fix your issue. Thanks for the reproducible example, I wouldn't be able to find the cause without it! |
@sebastien-comeau try v13.0.1 and let us know 😉 |
@adrai, problem seems to be resolved. Thanks for the collaboration. :) Intellisense still an issue for now: microsoft/TypeScript#54708 |
Hey, I have this issue in very specific case: only if the key or part of it is dynamic string "months": {
"1": "January",
"2": "February",
"3": "March",
...
} If I do: Versions:
|
@jamby77 create a minimal reproducible example repository and open a new issue |
🐛 Bug Report
After updating
react-i18next
from[11.16.2]
to[12.1.1]
, I have started getting an error on theuseTranslation
bit of the following line:const { t } = useTranslation('trans');
The error is:
Type instantiation is excessively deep and possibly infinite.ts(2589)
I can ignore it by using
/* @ts-ignore */
but that's not ideal. The error started appearing after the update and it's only on this single file (the whole app uses translation in the exact same way but strangely I am only getting this error here).To Reproduce
Cannot reproduce
Home.tsx
init-i18next.js
i18next.d.ts
Expected behavior
No errors were expected, like I had before the package update.
Your Environment
The text was updated successfully, but these errors were encountered: