Post
We found this while analyzing some relatively simple tRPC repos with bad language server performance. We didn't expect it to be so easy to repro: tsplay.dev/WG98oN
tsplay.devTS Playground - An online editor for exploring TypeScript and JavaScriptThe Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
Intersections including mapped types are lazily evaluated, but in many cases like this one, it appears they are never properly cached. Every time the type is referenced, it is re-instantiated, leading to O(3^N) scaling☠️
0 reposts9 likes
@ssalbdivad.dev and @andarist.bsky.social are looking into this now. We will let you know once me learn more and, god willing, have a PR soon 🙏
github.com[experiment] Cache mapper instantiations by Andarist · Pull Request #61505 · microsoft/TypeScript@ssalbdivad found out that a chain of somewhat trivial operations can easily end up with dreaded "Type instantiation is excessively deep and possibly infinite".
Two different reproduction...