-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Indexed Access TypesThe issue relates to accessing subtypes via index accessThe issue relates to accessing subtypes via index accessHelp WantedYou can do thisYou can do this
Milestone
Description
π Search Terms
visitType, visitObjectType, visitSymbol, RangeError, TypeScript Server Error
π Version & Regression Information
- This is the behavior in versions 5.9.2 and 6.0.0-dev.20250909
β― Playground Link
No response
π» Code
I'm not sure how to reproduce this at low level. I met this error in VS Code when it stopped showing "Extract" and "Move" groups in the "Refactor..." menu. Then I looked in the extension logs and saw an error in TS Server.
Steps to reproduce are:
- In an empty TypeScript project (tsconfig.json may be nonexistent), create a .ts file with:
function func<T, D>(param: ProblematicType<T, D>) {} type ProblematicType<T, D> = { prop: ProblematicType<T[keyof T], any>; }; class TestRefactoring<T> { createElement() { document.createElement('span'); } }
- Select
document.createElement('span');
- Make a right click on the selection
- Click "Refactor..."
π Actual behavior
- "Refactor..." menu:
- Extension Host logs in VS Code:
[error] [vscode.typescript-language-features] provider FAILED [error] Error: <semantic> TypeScript Server Error (6.0.0-dev.20250909) Maximum call stack size exceeded RangeError: Maximum call stack size exceeded at instantiateType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68177:27) at instantiateTypeWorker (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68263:9) at instantiateTypeWithAlias (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68210:20) at instantiateType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68178:29) at getMappedType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:67858:67) at <redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:67987:56 at map (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:2492:19) at getObjectTypeInstantiation (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:67987:29) at instantiateTypeWorker (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68235:16) at instantiateTypeWithAlias (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68210:20) at instantiateType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:68178:29) at getTypeOfInstantiatedSymbol (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:61397:40) at getTypeOfSymbol (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:61461:14) at visitSymbol (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:49811:17) at visitObjectType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:49796:9) at visitType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:49725:11) [...] at visitSymbol (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:49812:7) at visitObjectType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:49796:9) at visitType (<redacted>\.vscode\extensions\ms-vscode.vscode-typescript-next-6.0.20250909\node_modules\typescript\lib\typescript.js:49725:11) at n.create (<redacted>\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:2:357355) at y.dispatchResponse (<redacted>\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:2:30813) at y.dispatchMessage (<redacted>\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:2:29254) at ChildProcess.<anonymous> (<redacted>\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:2:28539) at ChildProcess.emit (node:events:518:28) at ChildProcess.emit (node:domain:489:12) at emit (node:internal/child_process:949:14) at processTicksAndRejections (node:internal/process/task_queues:91:21)
π Expected behavior
Additional information about the issue
The type ProblematicType
might not make sense to you, but it's a simplified (made as simple as I was able to) example of a real type in the @types/oojs library where I posted the issue as well, see DefinitelyTyped/DefinitelyTyped#73718.
For some reason, in VS Code this error appears only when the class is generic and an out of scope entity is referenced in the selection:
- If you remove the generic parameter from
TestRefactoring
, the error will be gone. - If you remove the
document
reference fromcreateElement()
and replace it withsmth
, the error will be gone.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Indexed Access TypesThe issue relates to accessing subtypes via index accessThe issue relates to accessing subtypes via index accessHelp WantedYou can do thisYou can do this