microsoft / microsoft/TypeScript

Regression: Maximum call stack exceeded in TypeScript 5.8.3 with large type inference

Open
#62,289 3 comments 0 reactions 0 assignees View on GitHub
Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Description:
We just upgraded our Angular app from version 18 to 20 and, consequently, our TS version to 5.8.3 (the latest compatible version with Angular 20) and are experiencing a "Maximum call stack exceeded" error when compiling our project with TypeScript 5.8.3 - but only in dev mode. It compiles without issue initially, but upon making any changes, we get this error. This appears to be a regression related to complex type inference or large type definitions and did not happen in Angular 18 when using TS 5.3.3.
This only happens in our complex app and not in simpler projects.

Reproduction Steps:
1. Install TypeScript 5.8.3 and and Angular 20 app with complex types.

Expected Behavior:
The project should compile successfully without a "Maximum call stack exceeded" error, as it did in TypeScript 5.3.3 and Angular 18.

Actual Behavior:
The compilation fails with
`
RangeError: Maximum call stack size exceeded
at getTypeAtFlowBranchLabel (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74199:38)
at getTypeAtFlowNode (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74009:48)
at getTypeAtFlowCondition (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74161:24)
at getTypeAtFlowNode (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74001:18)
at getTypeAtFlowCondition (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74161:24)
at getTypeAtFlowNode (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74001:18)
at getTypeAtFlowCondition (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74161:24)
at getTypeAtFlowNode (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74001:18)
at getTypeAtFlowCondition (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74161:24)
at getTypeAtFlowNode (/PATH_TO_FILE/node_modules/typescript/lib/typescript.js:74001:18)
`

Environment:
- TypeScript Version: 5.8.3
- Angular 20.1.5
- Node.js Version: 22.12.0
- Operating System: MacOS
- Build Tools: Vite - from Angular 20

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with TypeScript 5.8.3, Angular 20.1.5, Node.js 22.12.0, and Vite in the reported complex application. Inspect the stack around getTypeAtFlowBranchLabel, getTypeAtFlowNode, and getTypeAtFlowCondition, then compare with TypeScript 5.3.3. Done means identifying and resolving the regression so incremental compilation succeeds without a stack overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript, vite
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.