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.

"semantic error TS2589: Type instantiation is excessively deep and possibly infinite" with Zod 3.2

See original GitHub issue

For a simple type such as:-

export const ZCustomer = z.object({
	name: ZString()
});

where ZString is:- export const ZString = () => z.string().min(1)

I am getting a typescript error:-

semantic error TS2589: Type instantiation is excessively deep and possibly infinite

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
xargicommented, Jun 22, 2021

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?

3reactions
nikhilagcommented, Jun 18, 2021

@ingro Can you try with Typescript 4.1+? As mentioned in the documentation, Zod 3 requires TS 4.1+

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to ignore "Type instantiation is excessively deep and ...
After update to Typescript 3.5 i'm getting a lot of "Type instantiation is excessively deep and possibly infinite.ts(2589)" errors.
Read more >
TypeScript. Type instantiation is excessively deep ... - Ilya Zykin
Type instantiation is excessively deep and possibly infinite.ts(2589). Visual Studio Code IDE displays it to me for a component. The most unpleasant thing ......
Read more >
"I can't not brag about this — I solved a TypeScript issue in ...
An unintuitive error (“Type instantiation is excessively deep and possibly infinite”). Fixed by casting the type (IMessage) to the generic ...
Read more >
Error In Reactspring With Typescript For React
semantic error TS2589 : Type instantiation is excessively deep and possibly infinite with Zod 3.2. nikhilag opened this issue 4 months ago 11...
Read more >
Announcing TypeScript 4.7
It looks like the toughest upgrade though, I'm getting a lot of Type instantiation is excessively deep and possibly infinite errors.
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