Open mcmire opened 9 months ago
Some starting points for tackling the "Type instantiation is excessively deep" error:
0 extends 1
trick for extending tail recursion limit: https://github.com/microsoft/TypeScript/issues/49459This might not be enough to resolve the issue if the mutual recursion depth is infinite even with tail call elimination.
Might be resolved by TypeScript 5.5: https://github.com/microsoft/TypeScript/pull/57293
I checked the Immer repo and it looks like this problem still exists: https://github.com/immerjs/immer/issues/839
If you have an object type such as:
and you use it to change state within an Immer
produce
callback — such the callback thatupdate
in BaseController v2 takes — then you will get an error:This is happening because
Json
is a recursive type andDraft
andWritableDraft
trampoline as they recurse through thatJson
type. There's an open bug report on the Immer issue tracker with a proposed fix that was eventually reverted.We should work out some way to avoid this.