[BUG] Type instantiation is excessively deep and possibly infinite on latest TypeScript 4.5
See original GitHub issueThere is a new issue that appeared in TypeScript 4.5.0-dev.20211001 and exists until now.
To reproduce the error:
npm init -y
npm add zod
npm add -D typescript@next
echo 'import { z } from "zod";' > main.ts
echo '{"compilerOptions":{"lib":["es2020"]},"include":["main.ts"]}' > tsconfig.json
npx tsc -p .
TypeScript output:
node_modules/zod/lib/helpers/partialUtil.d.ts:4:29 - error TS2589: Type instantiation is excessively deep and possibly infinite.
4 [k in keyof Shape]: ZodOptional<DeepPartial<Shape[k]>>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
It affects the latest Zod (3.10.1), and also any other 3.x version. The issue appeared in https://github.com/microsoft/TypeScript/pull/41821 (producing a memory error), and later a check was added in https://github.com/microsoft/TypeScript/pull/46326 to prevent the infinite loop and give a meaningful message.
This is the same issue as #689 except that now we have an error message.
Demo code: https://github.com/mmvsk/zod-issue-715
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
TS 4.5 type instantiation is excessively deep and possibly ...
Bug Report There seem to be an issue with a very specific edge case: type F ... TS 4.5 type instantiation is excessively...
Read more >Why am I getting "Type instantiation is excessively deep and ...
You'll notice in the Playground link that action has the error: "Type instantiation is excessively deep and possibly infinite". I assume this is ......
Read more >Documentation - TypeScript 4.5
TypeScript 4.5 introduces a new utility type called the Awaited type. ... error: Type instantiation is excessively deep and possibly infinite.
Read more >TypeScript. Type instantiation is excessively deep ... - Ilya Zykin
Not always I know how to manage them. One of the messages is: Type instantiation is excessively deep and possibly infinite.ts(2589). Visual Studio...
Read more >Announcing TypeScript 4.5 RC - Microsoft Developer Blogs
TypeScript 4.5 introduces a new utility type called the Awaited type. ... Type instantiation is excessively deep and possibly infinite. type ...
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 FreeTop 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
Top GitHub Comments
Great minimal repro of the problem. I’m pretty sure we’re the only people who will every be affected by it 😛
My thoughts exactly 😃))
I posted this as a TS issue: https://github.com/microsoft/TypeScript/issues/46500
And indeed, it’s confirmed: