-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
Milestone
Description
TypeScript Version: 4.0.0-dev.20200615
Search Terms: recursive type, maximum call stack size exceeded
Code
type N<T, K extends string> = T | { [P in K]: N<T, K> }[K];
type M = N<number, "M">;
Expected behavior: To be honest, I'm not entirely sure what I would expect the type M
to be. Prior to 3.9, M
resolves to unknown
due to what I guess is the compiler giving up on instantiating the type which at least avoids a stack overflow. In this particular case, M
can only ever be number
regardless of how times the recursion is unfolded. Either way, I would not expect the compiler to crash.
Actual behavior: The compiler crashes due to a stack overflow when attempting to instantiate M
.
Related Issues: #38825
weswigham
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad output