typescript - 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?
解决方案
推荐阅读
- php - PHP Echos 和 headers - Echos 没有被输出
- sql - SQL 在查询中使用逗号分隔的字符串
- regex - 如何使用正则表达式修改我的变量值?
- android - 即使颁发它的 CA 不是,网络安全配置文件中的固定公钥是否受信任?
- python - 当 Conda 不是操作系统时,为什么会有特定于 Conda 的 Docker 映像?
- mysql - SQL按4张表中的数据搜索人
- ios - 如何在 Swift 中更改使用 VoiceOver 选择可拖动单元格的行为?
- google-sheets - 基于“,”的自动溢出单元格信息
- sql - 具有分组和聚合的 SQL 行到 Json 数组
- python - 设置 rasa nlu 时 httptools 构建失败