Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

Improve recursion identities and isDeeplyNestedType - #4913

Merged
Anders Hejlsberg (ahejlsberg) merged 4 commits into
mainfrom
fix-4807
Aug 18, 2026
Merged

Improve recursion identities and isDeeplyNestedType#4913
Anders Hejlsberg (ahejlsberg) merged 4 commits into
mainfrom
fix-4807

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

This PR

  • Improves recursion identities for indexed access types, and
  • Removes the "excessive stack depth" relation error.

See reasoning here.

Fixes #4807.

@ahejlsberg

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Aug 18, 2026

Copy link
Copy Markdown

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves recursive type relation handling to avoid false stack-depth errors for deeply circular structures.

Changes:

  • Refines recursion identities for indexed-access and mapped types.
  • Treats 100-level relation depth as indeterminate rather than erroneous.
  • Adds regression coverage and updates affected baselines.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/checker/relater.go Updates recursion detection and removes stack-depth diagnostics.
testdata/tests/cases/compiler/veryDeepRelations.ts Adds the circular-array regression case.
testdata/baselines/reference/compiler/veryDeepRelations.types Records expected type output.
testdata/baselines/reference/compiler/veryDeepRelations.symbols Records expected symbol output.
testdata/baselines/reference/compiler/excessivelyDeepConditionalTypes.errors.txt Removes obsolete stack-depth errors.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@typescript-automation

Copy link
Copy Markdown

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,480 115,480 ~ ~ ~ p=1.000 n=12
Types 96,945 96,945 ~ ~ ~ p=1.000 n=12
Memory Used 148,938k (± 0.51%) 149,351k (± 0.52%) ~ 147,770k 151,421k p=0.410 n=12
Memory Allocs 2,271,988 (± 0.00%) 2,272,092 (± 0.00%) ~ 2,271,839 2,272,362 p=0.128 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.040s (± 2.43%) 0.040s (± 3.94%) ~ 0.037s 0.047s p=0.176 n=12
Bind Time 0.013s (±13.92%) 0.013s (±11.37%) ~ 0.010s 0.017s p=0.611 n=12
Check Time 0.488s (± 0.79%) 0.485s (± 0.77%) ~ 0.479s 0.502s p=0.350 n=12
Emit Time 0.274s (± 1.72%) 0.272s (± 1.61%) ~ 0.257s 0.281s p=0.681 n=12
Total Time 0.822s (± 0.87%) 0.816s (± 0.86%) ~ 0.794s 0.837s p=0.224 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 847,930 (± 0.08%) 847,209 (± 0.08%) ~ 845,588 848,527 p=0.160 n=12
Types 249,912 (± 0.00%) 249,859 (± 0.00%) -53 (- 0.02%) 249,856 249,868 p=0.000 n=12
Memory Used 793,691k (± 0.08%) 792,977k (± 0.05%) -714k (- 0.09%) 792,151k 794,216k p=0.039 n=12
Memory Allocs 13,037,474 (± 0.03%) 13,036,470 (± 0.02%) ~ 13,032,120 13,045,624 p=0.671 n=12
Config Time 0.016s 0.016s ~ ~ ~ p=1.000 n=12
Parse Time 0.280s (± 2.66%) 0.283s (± 1.08%) ~ 0.274s 0.290s p=0.385 n=12
Bind Time 0.064s (± 9.40%) 0.059s (± 0.45%) 🟩-0.005s (- 8.17%) 0.058s 0.060s p=0.044 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.642s (± 1.20%) 1.630s (± 0.48%) ~ 1.610s 1.651s p=0.434 n=12
Total Time 2.023s (± 1.25%) 2.002s (± 0.45%) ~ 1.980s 2.028s p=0.091 n=12
mui-docs - native
Errors 11,279 (± 0.01%) 11,279 (± 0.01%) ~ 11,272 11,281 p=0.732 n=12
Symbols 4,602,406 4,592,664 -9,742 (- 0.21%) ~ ~ p=0.000 n=12
Types 1,639,118 1,636,666 -2,452 (- 0.15%) ~ ~ p=0.000 n=12
Memory Used 5,614,828k (± 0.04%) 5,567,394k (± 0.03%) -47,434k (- 0.84%) 5,565,259k 5,573,494k p=0.000 n=12
Memory Allocs 53,523,823 (± 0.04%) 53,332,087 (± 0.04%) -191,736 (- 0.36%) 53,279,229 53,408,996 p=0.000 n=12
Config Time 0.016s (± 1.81%) 0.016s (± 1.98%) ~ 0.015s 0.016s p=1.000 n=12
Parse Time 0.556s (± 2.05%) 0.550s (± 2.07%) ~ 0.511s 0.578s p=0.504 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 17.222s (± 0.37%) 17.164s (± 0.38%) ~ 16.937s 17.260s p=0.110 n=12
Emit Time 0.451s (± 2.68%) 0.479s (±15.64%) ~ 0.436s 0.854s p=0.880 n=12
Total Time 18.995s (± 0.40%) 18.970s (± 0.24%) ~ 18.815s 19.034s p=0.319 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,394,411 1,394,339 -72 (- 0.01%) ~ ~ p=0.000 n=12
Types 443,627 443,465 -162 (- 0.04%) ~ ~ p=0.000 n=12
Memory Used 1,652,649k (± 0.34%) 1,650,123k (± 0.28%) ~ 1,636,930k 1,661,651k p=0.347 n=12
Memory Allocs 97,232,180 (± 0.05%) 97,230,805 (± 0.04%) ~ 97,131,442 97,347,114 p=0.977 n=12
Config Time 0.004s (±12.64%) 0.003s (±16.58%) ~ 0.002s 0.005s p=0.337 n=12
Parse Time 0.196s (± 2.88%) 0.200s (± 2.68%) ~ 0.187s 0.215s p=0.385 n=12
Bind Time 0.000s (±217.90%) 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.780s (± 0.49%) 1.777s (± 0.29%) ~ 1.761s 1.787s p=0.966 n=12
Emit Time 0.287s (± 5.49%) 0.295s (± 2.66%) ~ 0.275s 0.312s p=0.417 n=12
Total Time 24.574s (± 0.84%) 24.650s (± 0.53%) ~ 24.338s 24.955s p=0.478 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 337,618 337,586 -32 (- 0.01%) ~ ~ p=0.000 n=12
Types 198,941 198,869 -72 (- 0.04%) ~ ~ p=0.000 n=12
Memory Used 319,661k (± 0.03%) 319,508k (± 0.02%) -154k (- 0.05%) 319,322k 319,626k p=0.010 n=12
Memory Allocs 4,676,796 (± 0.01%) 4,676,666 (± 0.01%) ~ 4,676,269 4,677,512 p=0.219 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.115s (± 5.17%) 0.111s (± 5.44%) ~ 0.099s 0.130s p=0.258 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.035s (± 0.47%) 1.032s (± 0.58%) ~ 1.015s 1.046s p=0.504 n=12
Emit Time 0.133s (±13.56%) 0.133s (±12.89%) ~ 0.103s 0.170s p=0.433 n=12
Total Time 1.338s (± 1.23%) 1.332s (± 1.28%) ~ 1.292s 1.376s p=0.724 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 305,341 305,317 -24 (- 0.01%) ~ ~ p=0.000 n=12
Types 182,038 181,984 -54 (- 0.03%) ~ ~ p=0.000 n=12
Memory Used 277,358k (± 0.02%) 277,271k (± 0.01%) -88k (- 0.03%) 277,154k 277,357k p=0.034 n=12
Memory Allocs 1,644,624 (± 0.02%) 1,644,200 (± 0.01%) -424 (- 0.03%) 1,643,752 1,644,724 p=0.017 n=12
Config Time 0.000s (±217.90%) 0.000s (±113.79%) ~ 0.000s 0.001s p=0.590 n=12
Parse Time 0.099s (± 3.59%) 0.100s (± 4.60%) ~ 0.090s 0.110s p=0.639 n=12
Bind Time 0.035s (± 9.95%) 0.038s (±13.17%) ~ 0.027s 0.050s p=0.324 n=12
Check Time 0.822s (± 0.51%) 0.820s (± 0.65%) ~ 0.802s 0.834s p=0.434 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.970s (± 0.76%) 0.973s (± 0.80%) ~ 0.948s 0.989s p=0.370 n=12
vscode - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 7,866,624 7,866,592 -32 (- 0.00%) ~ ~ p=0.000 n=12
Types 2,693,899 2,693,859 -40 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 5,286,397k (± 0.01%) 5,286,853k (± 0.02%) ~ 5,284,896k 5,289,052k p=0.443 n=12
Memory Allocs 40,983,928 (± 0.01%) 40,991,119 (± 0.03%) ~ 40,980,752 41,047,252 p=0.178 n=12
Config Time 0.061s (± 0.74%) 0.061s (± 0.59%) ~ 0.060s 0.062s p=0.355 n=12
Parse Time 1.601s (± 1.97%) 1.628s (± 1.47%) ~ 1.550s 1.687s p=0.091 n=12
Bind Time 0.363s (±17.69%) 0.338s (± 1.28%) ~ 0.331s 0.354s p=0.309 n=12
Check Time 9.485s (± 1.27%) 9.496s (± 0.98%) ~ 9.110s 9.580s p=0.921 n=12
Emit Time 3.193s (± 9.85%) 3.147s (± 5.55%) ~ 2.985s 3.937s p=0.899 n=12
Total Time 14.783s (± 1.65%) 14.751s (± 0.64%) ~ 14.640s 15.197s p=0.164 n=12
webpack - native
Errors 2 2 ~ ~ ~ p=1.000 n=12
Symbols 1,380 1,380 ~ ~ ~ p=1.000 n=12
Types 340 340 ~ ~ ~ p=1.000 n=12
Memory Used 198,774k (± 0.07%) 198,708k (± 0.05%) ~ 198,329k 198,868k p=0.843 n=12
Memory Allocs 841,484 (± 0.14%) 841,678 (± 0.22%) ~ 839,659 847,991 p=0.932 n=12
Config Time 0.008s (± 4.74%) 0.008s (± 4.45%) ~ 0.008s 0.010s p=1.000 n=12
Parse Time 0.218s (± 2.73%) 0.217s (± 1.98%) ~ 0.202s 0.227s p=0.522 n=12
Bind Time 0s 0s ~ ~ ~ p=1.000 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.227s (± 2.77%) 0.226s (± 1.97%) ~ 0.210s 0.237s p=0.486 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,020,005 1,019,981 -24 (- 0.00%) ~ ~ p=0.000 n=12
Types 376,891 376,182 -709 (- 0.19%) ~ ~ p=0.000 n=12
Memory Used 603,515k (± 0.02%) 603,286k (± 0.02%) -229k (- 0.04%) 603,033k 603,541k p=0.003 n=12
Memory Allocs 4,750,574 (± 0.04%) 4,750,125 (± 0.05%) ~ 4,743,135 4,756,476 p=0.887 n=12
Config Time 0.003s 0.003s ~ ~ ~ p=1.000 n=12
Parse Time 0.146s (± 3.86%) 0.146s (± 3.73%) ~ 0.130s 0.160s p=0.723 n=12
Bind Time 0.045s (±16.11%) 0.045s (±18.31%) ~ 0.033s 0.067s p=0.943 n=12
Check Time 1.022s (± 1.06%) 1.025s (± 1.11%) ~ 0.999s 1.062s p=0.723 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.229s (± 1.20%) 1.230s (± 1.14%) ~ 1.199s 1.258s p=0.966 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown

Anders Hejlsberg (@ahejlsberg) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/4913/merge:

Everything looks good!

@ahejlsberg
Anders Hejlsberg (ahejlsberg) added this pull request to the merge queue Aug 18, 2026
Merged via the queue into main with commit 12548e2 Aug 18, 2026
22 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False “Excessive stack depth” on circular types linked through arrays (regression from #3445)

3 participants