Skip to content

Type instantiation is excessively deep and possibly infinite. #2609

@TkDodo

Description

@TkDodo

Steps to reproduce

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAKjgQwM5wEoFNkGN4BmUEIcA5FDvmQFCiSxwDeArqlgGLQgC+cRJcgAEYyAHapRuANYB6SnhgBaAtzIBuOuGjwmALz4DSZPRAAmGmnTEwsUAnixwACsTCoAPDThwAKgGVcAAssEGQ4LAAPWzEzdD0AOgAtcwB5ACMAKyx8D0SUswxkAHd-IOQwLAA+ABpvPw5gLAAbMwA5ZBAnKJi4uABRaKhFD2ksAE8IAjhE4DECOw8A4NDkWrhJKDmAc1qaKuZ6ueAYYGRmgDVzliwALhmEuYWoJcCQsKqAbV9GlvbOrAAXU0PjEAPuPyarQ6XRBGxWYQhb1Wmh4ViiDEILDE+GAEDEmCwYGIXh8y3e4R6WFi8WSaSyORgeTphRKZQq1TqZN+0IBEWi1L6gxgw1yY0m01m80W5NW602Oz2VQAFEwwV0anBjqdzldmjcePdXBB3K8EchNZC-jDqgBKQ4+XD4yT8bhwAC8cDYnG4qvqPjMWAcLGaMD1N1Q9yYn3VQPu2rOl2uWB4XLgPFtmnqlBgLCgBI8qigIASPLMcFj7rVAJ4VSYBCh5fdBw8ZmAADc6w2-glYzwPLI253+7IiyWy1VUVYnRJ4KhzR6HhAGfg-T5VBB7okFWJtsrbTQM1YCNjcfi-FhJPvDtmsLn83Blf64B5sMSIPCKVX5xS+JWAEQbv+WpiCcibhlg7r-ukyBQMBshVPUB48EAA

Sorry that this isn’t more minimal, as it still uses two external libraries (TanStack Form and zod), but I have trimmed it down from the original as much as possible.

As discussed with Jake on Bluesky, this could very well be an issue with TanStack Form’s typings, but I’d still expect tsgo and ts 5.9 to behave identically.

Behavior with typescript@5.9

no error

Behavior with tsgo

Error in line 22:

Type instantiation is excessively deep and possibly infinite.


As a workaround, we can cast defaultValues:

defaultValues: {[name]: initialValue} as Record<TFieldName,z.infer<TSchema>[TFieldName]>

Metadata

Metadata

Assignees

Labels

Domain: Type CheckingRelated to type checking, grammar checkingType OrderingAn issue related to ordering of types

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions