-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TSServer hangs when using recursive types on tuples and pressing "," #26155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Reproduced in a fourslash test: /// <reference path='fourslash.ts'/>
////type Tail<T extends any[]> =
//// ((...args: T) => any) extends ((head: any, ...tail: infer R) => any) ? R : never;
////
////type Reverse<List extends any[]> = _Reverse<List, []>;
////
////type _Reverse<Source extends any[], Result extends any[] = []> = {
//// 1: Result,
//// 0: _Reverse<Tail<Source>, 0>,
////}[Source extends [] ? 1 : 0];
////
////type Foo = Reverse<[0,/**/]>;
verify.signatureHelp({
marker: "",
text: "?",
}); |
Potentially relevant: While the process hangs, its RAM usage continues to rise - as if its building some infinite signature help or something like that. |
afaik TS did do stuff on trailing comma for Intellisense purposes... not sure what's happening here though. |
Update: Using typescript@3.1.0-dev.20180824, the original code no longer completely freezes the language server. It's still incredibly slow, but works. |
@sheetalkamat @RyanCavanaugh |
with typescript@next there is no huge type generated that I can repro with your example. |
Disclaimer: This is probably not intended use of the type system but it might show an underlying issue so I still report it.
TypeScript Version: 3.1.0-dev.20180802
Search Terms: recursive conditional type tuple freeze
Code
While experimenting with the examples found in #24897 (comment), I noticed some weird behavior when it comes to recursive types. Apparently tail recursion on type members seems to work, which means it can be used to create crazy types like
Reverse
:When opening a file where that type is used, VSCode's Intellisense shows the correct type after a minor delay:
After adding a comma after the 3 in the recursive type, TSServers comes to a halt (1 core with full CPU usage).
However, if I paste a comma and a number from somewhere else in a single operation, it works just fine:
The same thing happens when changing a type to this recursive type
but not doing it in this order:
Related Issues: #24897
The text was updated successfully, but these errors were encountered: