You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"RangeError: Maximum call stack size exceeded" error after upgrading from 5.6.3 to 5.7.2 #60564
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)
It shouldn't happen but I'm not entirely convinced that it's a repro case for your original problem. This crashes when calling reportNonexistentProperty so it feels like an extra repro for #60336 (that said... a new one cause your issue is pretty new and that can be reproduced with older TS versions). I assume that you've wanted to report an issue for a code that doesn't error on 5.6.3. Once we add a missing property, this repro stops crashing: TS playground
The above repro is caused by the fact that typeFromObjectLiteral calls inferExpressionType nowadays despite !canGetTypeFromObjectLiteral(objectLiteral, context). Previously it bailed out of this function and just returned false in this case.
We have a similar stacktrace and issue. With version 5.6.3 it is working and building but with the latest 5.7.2 its failing with the following stacktrace:
node:internal/process/promises:289
triggerUncaughtException(err, true /* fromPromise */);
^
RangeError: Maximum call stack size exceeded
at getJSDocType (D:\a\1\s\node_modules\typescript\lib\typescript.js:15151:22)
at getEffectiveTypeAnnotationNode (D:\a\1\s\node_modules\typescript\lib\typescript.js:20389:91)
at getContextualTypeForVariableLikeDeclaration (D:\a\1\s\node_modules\typescript\lib\typescript.js:75985:22)
at getContextualTypeForObjectLiteralElement (D:\a\1\s\node_modules\typescript\lib\typescript.js:76477:69)
at getContextualType2 (D:\a\1\s\node_modules\typescript\lib\typescript.js:76770:16)
at getApparentTypeOfContextualType (D:\a\1\s\node_modules\typescript\lib\typescript.js:76689:120)
at getContextualTypeForObjectLiteralElement (D:\a\1\s\node_modules\typescript\lib\typescript.js:76481:18)
at getContextualTypeForObjectLiteralMethod (D:\a\1\s\node_modules\typescript\lib\typescript.js:76473:12)
at getApparentTypeOfContextualType (D:\a\1\s\node_modules\typescript\lib\typescript.js:76689:58)
at getContextualSignature (D:\a\1\s\node_modules\typescript\lib\typescript.js:77088:18)
Hmm. Interesting. It's definitely that line of code, commenting out the equivalent of [this.a]: "", in our codebase fixes the error. But it is puzzling that the stack is different here. Maybe it changed between 5.7 and 5.8? I can't tell with the minified stack for 5.7 in the playground :/
Activity
Andarist commentedon Nov 22, 2024
According to the provided bisect information it's caused by something in this diff.
To fix this a repro case has to be provided though.
epmatsw commentedon Nov 22, 2024
Got it! https://www.typescriptlang.org/play/?ts=5.8.0-dev.20241122#code/KYDwDg9gTgLgBAYwgOwM7xgCwJbIOZwC8cA3gFACQAJhNjABQCUplFUwMArlMixfwG0s2VADoAhgF0AXHABEcgDSsAvgG5KK5eqA
epmatsw commentedon Nov 22, 2024
It doesn't show up in the UI for some reason, but in the console you can see an uncaught promise rejection:
Andarist commentedon Nov 22, 2024
It shouldn't happen but I'm not entirely convinced that it's a repro case for your original problem. This crashes when calling
reportNonexistentPropertyso it feels like an extra repro for #60336 (that said... a new one cause your issue is pretty new and that can be reproduced with older TS versions). I assume that you've wanted to report an issue for a code that doesn't error on 5.6.3. Once we add a missing property, this repro stops crashing: TS playgroundAndarist commentedon Nov 22, 2024
The above repro is caused by the fact that
typeFromObjectLiteralcallsinferExpressionTypenowadays despite!canGetTypeFromObjectLiteral(objectLiteral, context). Previously it bailed out of this function and just returnedfalsein this case.cgockeln42 commentedon Nov 25, 2024
We have a similar stacktrace and issue. With version 5.6.3 it is working and building but with the latest 5.7.2 its failing with the following stacktrace:
epmatsw commentedon Dec 2, 2024
Hmm. Interesting. It's definitely that line of code, commenting out the equivalent of
[this.a]: "",in our codebase fixes the error. But it is puzzling that the stack is different here. Maybe it changed between 5.7 and 5.8? I can't tell with the minified stack for 5.7 in the playground :/