首页 > 解决方案 > Isolate cause of Typescript max recursion error with getAwaitedTypeWorker => getAwaitedType => mapType

问题描述

We have a large Typescript codebase using Typescript 4.4.2 in VS Code and with certain larger TSX files we are seeing the Typescript hints and types freeze regularly.

Under the VS Code Output => Log (Extension Host) this is the error we are seeing:

RangeError: Maximum call stack size exceeded
    at getPromisedTypeOfPromise (/my/repo/node_modules/typescript/lib/tsserver.js:77328:42)
    at getAwaitedTypeWorker (/my/repo/node_modules/typescript/lib/tsserver.js:77418:32)
    at mapType (/my/repo/node_modules/typescript/lib/tsserver.js:66541:97)
    at getAwaitedType (/my/repo/node_modules/typescript/lib/tsserver.js:77411:17)
    at getAwaitedTypeWorker (/my/repo/node_modules/typescript/lib/tsserver.js:77462:35)
    at mapType (/my/repo/node_modules/typescript/lib/tsserver.js:66541:97)
    at getAwaitedType (/my/repo/node_modules/typescript/lib/tsserver.js:77411:17)
    at getAwaitedTypeWorker (/my/repo/node_modules/typescript/lib/tsserver.js:77462:35)
...
    at getAwaitedType (/my/repo/node_modules/typescript/lib/tsserver.js:77411:17)
    at Function.create (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:460421)
    at dispatchResponse (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:454257)
    at dispatchMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:453114)
    at /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:452599
    at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:66:1712)
    at m.onLengthData (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:463350)
    at Socket.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:1:462997)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)

We have a thousands of references to Promise, await and async throughout the codebase and there's no obvious culprit in the TSX file in question. Curiously the affected files have no direct references to Promise, await, or async, though they certainly include types that do. It's not apparent how to isolate the problematic case.

Is there any way to help find out what the TS language server is circularly referencing here?

标签: typescriptvisual-studio-codevscode-extensions

解决方案


推荐阅读