Skip to content

Circular instantiation expression crashing IDEsΒ #51202

@jcalz

Description

@jcalz

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

  • signatureToSignatureDeclarationHelper
  • createTypeNodeFromObjectType
  • createAnonymousTypeNode
  • typeToTypeNodeWorker
  • typeToTypeNodeHelper
  • serializeReturnTypeForSignature
  • signatureToSignatureDeclarationHelper
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Type DisplayBugs relating to showing types in Quick Info/Tooltips, Signature Help, or Completion InfoFix AvailableA PR has been opened for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions