-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
"semantic error TS2589: Type instantiation is excessively deep and possibly infinite" with Zod 3.2 #495
Comments
Got the same problem on a relatively simple type: z.object({
name: z.string().nonempty(),
city: z.string().min(3),
}) I'm using Zod 3.2.0 too but with an older Typescript version, 4.0.5. |
@ingro Can you try with Typescript 4.1+? As mentioned in the documentation, Zod 3 requires TS 4.1+ |
@nikhilag You're right, this is resolved by upgrading typescript. |
Unfortunately it's happening in my case even with the latest typescript (see my message above). Do I need to downgrade typescript to an older version in case latest is not supported? |
Having trouble replicating this @nikhilag, make sure your version of TypeScript is the one being used by VSCode. Otherwise try creating a replication repo. |
Thanks for checking this @colinhacks |
Also running into this issue with Typecsript 4.3.2 and Zod 3.2. It occurs intermittently, which makes replicating likely difficult. Running tsc or jest twice in a row will throw the error one time and compile perfectly fine the next. So far it seems to only occur on object schemas, even simple ones. Maybe something to do with memory pressure? |
The issue in my case was with tsdx. It seems tsdx was using an old version of typescript to build and hence I was running into that error. See jaredpalmer/tsdx#1044 for reference along with suggested fix. |
@nikhilag Two other people just reported similar issues but I still can't reproduce it. I know it's been a while but do you think you could put together a reproduction repo? |
@colinhacks Having the same issue on a random
And that seems to have resolved my errors. |
I had a complex schema that was working fine and now I get this error from time to time.
Tried removing node_modules and reinstalling, didn't help. Reduced schema to var PostOffer = z.object({
offer: z.object({}),
}); which helped for this
|
Just as an update for others running into the problem:
After deriving a
(Restarting VScode before going (Maybe the workspace from which the schema is imported had been compiled with the OS |
For a simple type such as:-
where ZString is:-
export const ZString = () => z.string().min(1)
I am getting a typescript error:-
I am using typescript 4.3.2 with Zod 3.2.0 in a tsdx 0.14.1 setup. Not sure what's wrong here.
The text was updated successfully, but these errors were encountered: