microsoft / microsoft/TypeScript
Crash: RangeError: Maximum call stack size exceeded during contextual typing of object literal with yield in computed property name
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
🔎 Search Terms
RangeError: Maximum call stack size exceeded
checkYieldExpression recursion
getContextualTypeForObjectLiteralElement crash
Computed property name generator yield
🕗 Version & Regression Information
Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly
Behavior: All tested versions crash.
Precondition: Only crashes when the variable has an explicit type annotation (e.g., : any).
Comparison: let x = { ... } (inference) does not crash; let x: any = { ... } (contextual typing) crashes.
⏯ Playground Link
💻 Code
function* g() {
// The explicit ': any' is required to trigger the crash
let x:any = {
*[yield 0]() {
}
};
}
🙁 Actual behavior
.\ts-versions\nightly\node_modules\.bin\tsc.cmd C:\Users\aw\Desktop\itr\result0\mutated\generatorTypeCheck43_mutated_iter7.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123181
throw e;
^
RangeError: Maximum call stack size exceeded
at hasSyntacticModifier (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:16878:30)
at getFunctionFlags (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:15771:11)
at checkYieldExpression (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80294:27)
at checkExpressionWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80953:16)
at checkExpression (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:80809:32)
at getContextualTypeForObjectLiteralElement (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73061:28)
at getContextualTypeForObjectLiteralMethod (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73044:12)
at getApparentTypeOfContextualType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73260:58)
at getContextualSignature (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73692:18)
at getContextualSignatureForFunctionLikeDeclaration (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:73684:87)
Node.js v22.19.0
🙂 Expected behavior
The compiler should not crash.
Additional information about the issue
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reduced TypeScript example and the compiler paths named in the stack trace: checkYieldExpression, getContextualTypeForObjectLiteralElement, getContextualTypeForObjectLiteralMethod, and getContextualSignature. Run the repro with the explicit any annotation, then compare it with inferred typing. Done means the compiler reports no stack overflow for the computed-property generator case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100