TypeScript
TypeScript copied to clipboard
Circular instantiation expression crashing IDEs
Bug Report
🔎 Search Terms
instantiation expressions, circular, IntelliSense, quickinfo, crash
🕗 Version & Regression Information
- This is a crash (in IntelliSense in editors anyway)
⏯ Playground Link
Playground link with relevant code
💻 Code
declare function foo<T>(t: T): typeof foo<T>;
foo("");
🙁 Actual behavior
Hovering over the call to foo() gives "too much recursion" errors in the TS Language server. Looks like a loop in
signatureToSignatureDeclarationHelpercreateTypeNodeFromObjectTypecreateAnonymousTypeNodetypeToTypeNodeWorkertypeToTypeNodeHelperserializeReturnTypeForSignaturesignatureToSignatureDeclarationHelper
call stack
Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at process.hrtime (node:internal/process/per_thread:79:16)
at Performance.now (node:internal/perf/utils:14:22)
at ts.timestamp (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:3634:79)
at ThrottledCancellationToken.isCancellationRequested (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:166867:27)
at CancellationTokenObject.isCancellationRequested (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:166844:43)
at CancellationTokenObject.throwIfCancellationRequested (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:166847:22)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53001:39)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeTypeForDeclaration (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54543:30)
at symbolToParameterDeclaration (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53970:41)
at c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53881:274
at Array.map (<anonymous>)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53881:240)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
at typeToTypeNodeHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:52995:32)
at serializeReturnTypeForSignature (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:54571:24)
at signatureToSignatureDeclarationHelper (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53901:42)
at createTypeNodeFromObjectType (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53457:49)
at createAnonymousTypeNode (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53359:32)
at typeToTypeNodeWorker (c:\Users\jcalz\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:53204:28)
🙂 Expected behavior
Maybe a circularity warning, but definitely no crash
This came up when trying to look at the code in a Stack Overflow question and wondering why the IDE was acting so strange.
If this is causing a crash it's almost certainly in the TS language server, so definitely a TS issue. Do you have a callstack?
Edited call stack in above.
Looks like a loop in
signatureToSignatureDeclarationHelper
createTypeNodeFromObjectType
createAnonymousTypeNode
typeToTypeNodeWorker
typeToTypeNodeHelper
serializeReturnTypeForSignature