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
Template literal union type-checking is exponentially slower when type is explicitly annotated vs inferred #63653
// repro-inferred.tsnewclass{privatemap: Record<string,TypeName[]>={x: ['f_0|i_0']}constructor(){letitem// <== inferred, no explicit annotation (this is the ONLY difference to 'repro.ts')if(this.map.x){const[entry]=this.map.xitem=entry}console.log('item:',item)}}()
This might not be a bug; // repro-inferred.ts really does have to do less work than // repro.ts - the latter has to do an assignability check, the former does not.
This might not be a bug; // repro-inferred.ts really does have to do less work than // repro.ts - the latter has to do an assignability check, the former does not.
Tried to profile where the CPU spends the most time for tsc6, most work occurs around isTypeRelatedTo / isFreshLiteralType / isSimpleTypeRelatedTo and typeMaybeAssignableTo.
The exponential behavior was the reason to call it a bug.
The culprit here is the getAssignmentReducedType in control flow analysis which can exhibit quadratic behavior when the declaredType and assignedType arguments are both large union types. There's a simple optimization that dramatically reduces the overhead. I'll put up a PR.
Activity
RyanCavanaugh commentedon Jul 16, 2026
This might not be a bug;
// repro-inferred.tsreally does have to do less work than// repro.ts- the latter has to do an assignability check, the former does not.LangLangBart commentedon Jul 19, 2026
Tried to profile where the CPU spends the most time for tsc6, most work occurs around
isTypeRelatedTo/isFreshLiteralType/isSimpleTypeRelatedToandtypeMaybeAssignableTo.The exponential behavior was the reason to call it a bug.
CPU time spent:
ahejlsberg commentedon Jul 23, 2026
The culprit here is the
getAssignmentReducedTypein control flow analysis which can exhibit quadratic behavior when thedeclaredTypeandassignedTypearguments are both large union types. There's a simple optimization that dramatically reduces the overhead. I'll put up a PR.LangLangBart commentedon Jul 24, 2026
Thx. Tested the latest nightly with your fix vs the day prior on the repro repo:
✅ Issue fixed