You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main.ts:16:9 - error TS2589: Type instantiation is excessively deep and possibly infinite.
16 return g() as F<any>;
~~~
However, this code worked with typescript prior to 4.5.0-dev.20211001 (so 4.4), and what's unusual, changing almost anything in this code removes the error, such as:
return f<any>() as F<any>; (and it should be exactly the same as it's function f<T = any>() [?])
return f();
replacing { x: unknown } with {}
removing T extends any[]
removing T extends [any, ...any[]]
or using F<T[number]>[] instead of { [K in keyof T]?: F<T[K]> }
TS 4.4...
🔎 Search Terms
type instantiation is excessively deep and possibly infinite
It returned the possibily related #46404, howver, it was not fixed in #46429 as the comments suggest (still present in latest 4.5.0-dev.20211023).
🕗 Version & Regression Information
Appeared in TypeScript 4.5.0-dev.20211001 (worked until 4.5.0-dev.20210930). Probably it was introduced with PR #41821, it caused then an infinite loop that resulted in a "JS heap out of memory" error. Then, with PR #46326, the problem was caught and the above message appeared.
The text was updated successfully, but these errors were encountered:
Yeah, that isn't right. The issue here is that we bypass caching of relations for small unions and intersections, but that bypass also causes us to loose a check for deeply nested types that would have stopped the recursion. It used to not matter, but after #41821 it does. We need to revise our logic such that we can bypass caching but still check for deep nesting.
Bug Report
There seem to be an issue with a very specific edge case:
Gives the following error:
However, this code worked with typescript prior to
4.5.0-dev.20211001
(so 4.4), and what's unusual, changing almost anything in this code removes the error, such as:return f<any>() as F<any>;
(and it should be exactly the same as it'sfunction f<T = any>()
[?])return f();
{ x: unknown }
with{}
T extends any[]
T extends [any, ...any[]]
F<T[number]>[]
instead of{ [K in keyof T]?: F<T[K]> }
🔎 Search Terms
It returned the possibily related #46404, howver, it was not fixed in #46429 as the comments suggest (still present in latest
4.5.0-dev.20211023
).🕗 Version & Regression Information
Appeared in TypeScript
4.5.0-dev.20211001
(worked until4.5.0-dev.20210930
). Probably it was introduced with PR #41821, it caused then an infinite loop that resulted in a "JS heap out of memory" error. Then, with PR #46326, the problem was caught and the above message appeared.The text was updated successfully, but these errors were encountered: