Skip to content

"RangeError: Maximum call stack size exceeded" error after upgrading from 5.6.3 to 5.7.2 #60564

@epmatsw

Description

@epmatsw

🔎 Search Terms

"Maximum call stack size exceeded", "getContextualTypeForObjectLiteralElement", "checkNonNullExpression"

🕗 Version & Regression Information

This changed between versions 5.7.0-dev.20240930 and 5.7.0-dev.20241001

I ran into this bug upgrading from 5.6.3 to 5.7.2 and bisected to that particular release.

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.8.0-dev.20241122#code/KYDwDg9gTgLgBAYwgOwM7xgCwJbIOZwC8cA3gFACQAJhNjABQCUplFUwMArlMixfwG0s2VADoAhgF0AXHABEcgDSsAvgG5KK5eqA

💻 Code

I don't have a narrowed code example, it just crashes when running tsc --noEmit on our whole project.

🙁 Actual behavior

RangeError: Maximum call stack size exceeded
    at getContextualTypeForObjectLiteralElement (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71872:52)
    at getContextualTypeForObjectLiteralMethod (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71870:12)
    at getApparentTypeOfContextualType (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:72086:58)
    at getContextualSignature (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:72485:18)
    at getContextualThisParameterType (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71308:35)
    at tryGetThisTypeAt (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71103:33)
    at checkThisExpression (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71061:18)
    at checkExpressionWorker (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:79624:16)
    at checkExpression (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:79564:32)
    at checkNonNullExpression (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:73599:29)

🙂 Expected behavior

No crash

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions