Skip to content

Preserve reverse mapped types in declaration emit - #64558

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:fix-reverse-mapped-declarations
Oct 1, 2026
Merged

Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
jakebailey:fix-reverse-mapped-declarations

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Gets rid of more silently-produced elided anys. See the second commit for the actual change.

Reverse-mapped property and index signature types are lost in emitted
declarations even when source consumers retain them. Cover finite nested
shapes, recursive inputs, and consumers of the generated declarations.
Display placeholders discard real property and index signature types
when reused for declaration emit. Preserve those types in declarations
while leaving editor display unchanged.

Reverse-mapped types without symbols can still recurse. Track their type
identities and bound expansion by mapped declaration when changing type
arguments prevent repetition. Report cycles and truncation rather than
silently replacing these types with any.

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.

Copilot review overview

🟢 Approval recommended

The implementation preserves declaration accuracy, bounds recursive expansion, and includes comprehensive regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Preserves inferred reverse-mapped types during declaration emit while retaining concise Quick Info display behavior.

Changes:

  • Expands reverse-mapped properties and index signatures for declarations.
  • Adds recursion and growth safeguards.
  • Adds compiler, incremental-build, and Quick Info coverage.
File Description
tsc/​internal/​checker/​nodebuilderimpl.go Implements declaration serialization and recursion limits.
tsc/​testdata/​tests/​cases/​compiler/​reverseMappedDeclarationSerialization.ts Covers finite and recursive mappings.
tsc/​internal/​fourslash/​tests/​reverseMappedDeclarationQuickInfo_test.go Tests Quick Info behavior.
tsc/​internal/​execute/​tsctests/​tsc_test.go Tests incremental declaration consumption.
tsc/​testdata/​baselines/​reference/​compiler/​reverseMappedDeclarationSerialization.js Records emit results.
tsc/​testdata/​baselines/​reference/​compiler/​reverseMappedDeclarationSerialization.errors.txt Records recursion diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​reverseMappedDeclarationSerialization.symbols Records symbol baselines.
tsc/​testdata/​baselines/​reference/​compiler/​reverseMappedDeclarationSerialization.types Records inferred-type baselines.
tsc/​testdata/​baselines/​reference/​fourslash/​quickInfo/​reverseMappedDeclarationQuickInfo.baseline Records hover output.
tsc/​testdata/​baselines/​reference/​tsbuild/​incremental/​reverse-mapped-declaration-consumption.js Records incremental-build behavior.

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

@jakebailey

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

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

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing 792ffccb90f548cd3bdd7fc0b44f0ca9e1b169a7 and refs/pull/64558/merge:

Everything looks good!

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
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,276 115,276 ~ ~ ~ p=1.000 n=12
Types 79,613 79,613 ~ ~ ~ p=1.000 n=12
Memory Used 141,231k (± 0.44%) 141,832k (± 0.47%) ~ 140,043k 143,716k p=0.053 n=12
Memory Allocs 2,194,734 (± 0.01%) 2,194,570 (± 0.00%) -165 (- 0.01%) 2,194,354 2,194,770 p=0.046 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.041s (± 4.05%) 0.041s (± 3.25%) ~ 0.038s 0.045s p=0.893 n=12
Bind Time 0.014s (±10.03%) 0.013s (±10.11%) ~ 0.010s 0.016s p=0.576 n=12
Check Time 0.500s (± 0.86%) 0.510s (± 1.12%) +0.010s (+ 1.98%) 0.498s 0.524s p=0.016 n=12
Emit Time 0.267s (± 1.99%) 0.268s (± 1.77%) ~ 0.258s 0.283s p=0.988 n=12
Total Time 0.828s (± 0.82%) 0.838s (± 1.00%) +0.010s (+ 1.22%) 0.816s 0.859s p=0.037 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 846,623 (± 0.09%) 846,264 (± 0.13%) ~ 843,478 848,415 p=0.755 n=12
Types 249,940 (± 0.00%) 249,940 (± 0.00%) ~ 249,938 249,949 p=0.078 n=12
Memory Used 789,198k (± 0.06%) 789,106k (± 0.05%) ~ 788,146k 790,334k p=0.977 n=12
Memory Allocs 12,938,276 (± 0.07%) 12,933,709 (± 0.02%) ~ 12,930,716 12,940,995 p=1.000 n=12
Config Time 0.016s 0.016s ~ ~ ~ p=1.000 n=12
Parse Time 0.265s (± 2.89%) 0.269s (± 2.51%) ~ 0.246s 0.284s p=0.640 n=12
Bind Time 0.071s (±19.13%) 0.064s (±13.10%) ~ 0.057s 0.103s p=0.322 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.612s (± 1.43%) 1.613s (± 1.74%) ~ 1.570s 1.706s p=0.989 n=12
Total Time 1.982s (± 1.64%) 1.979s (± 1.69%) ~ 1.932s 2.078s p=0.965 n=12
mui-docs - native
Errors 11,400 (± 0.04%) 11,396 (± 0.06%) ~ 11,374 11,405 p=0.615 n=12
Symbols 4,450,780 4,450,780 ~ ~ ~ p=1.000 n=12
Types 1,441,847 1,441,847 ~ ~ ~ p=1.000 n=12
Memory Used 3,190,939k (± 0.05%) 3,190,663k (± 0.05%) ~ 3,183,874k 3,193,553k p=0.671 n=12
Memory Allocs 34,634,841 (± 0.05%) 34,636,172 (± 0.04%) ~ 34,609,953 34,680,625 p=0.932 n=12
Config Time 0.016s (± 1.98%) 0.015s (± 2.02%) ~ 0.015s 0.016s p=0.220 n=12
Parse Time 0.580s (± 1.42%) 0.587s (± 2.07%) ~ 0.535s 0.605s p=0.075 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 8.679s (± 1.19%) 8.670s (± 1.26%) ~ 8.500s 8.967s p=0.921 n=12
Emit Time 0.577s (±15.18%) 0.580s (±14.60%) ~ 0.428s 0.716s p=0.966 n=12
Total Time 10.613s (± 0.46%) 10.627s (± 0.55%) ~ 10.497s 10.819s p=0.702 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,390,229 1,390,229 ~ ~ ~ p=1.000 n=12
Types 441,498 441,498 ~ ~ ~ p=1.000 n=12
Memory Used 1,686,148k (± 0.89%) 1,687,916k (± 0.81%) ~ 1,648,674k 1,709,606k p=0.977 n=12
Memory Allocs 92,697,543 (± 0.13%) 92,808,499 (± 0.09%) ~ 92,567,578 92,977,749 p=0.089 n=12
Config Time 0.004s (±13.41%) 0.004s (±19.92%) ~ 0.002s 0.007s p=0.738 n=12
Parse Time 0.211s (± 3.53%) 0.211s (± 2.95%) ~ 0.194s 0.230s p=0.702 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.810s (± 0.54%) 1.822s (± 0.57%) ~ 1.792s 1.847s p=0.147 n=12
Emit Time 0.309s (± 4.77%) 0.305s (± 2.91%) ~ 0.273s 0.323s p=0.401 n=12
Total Time 23.534s (± 0.49%) 23.652s (± 0.63%) ~ 23.218s 24.000s p=0.319 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 334,953 334,953 ~ ~ ~ p=1.000 n=12
Types 197,616 197,616 ~ ~ ~ p=1.000 n=12
Memory Used 313,347k (± 0.09%) 313,210k (± 0.03%) ~ 312,951k 313,420k p=0.590 n=12
Memory Allocs 4,628,249 (± 0.01%) 4,628,053 (± 0.01%) ~ 4,627,200 4,629,035 p=0.541 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.114s (± 4.99%) 0.116s (± 5.88%) ~ 0.095s 0.131s p=0.580 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.050s (± 0.53%) 1.058s (± 0.60%) +0.008s (+ 0.78%) 1.038s 1.073s p=0.040 n=12
Emit Time 0.132s (± 9.27%) 0.133s (±12.74%) ~ 0.096s 0.174s p=0.560 n=12
Total Time 1.349s (± 0.55%) 1.361s (± 1.04%) ~ 1.323s 1.396s p=0.147 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 303,834 303,834 ~ ~ ~ p=1.000 n=12
Types 181,663 181,663 ~ ~ ~ p=1.000 n=12
Memory Used 273,926k (± 0.02%) 273,851k (± 0.02%) ~ 273,736k 274,032k p=0.068 n=12
Memory Allocs 1,617,992 (± 0.01%) 1,618,015 (± 0.02%) ~ 1,617,493 1,618,630 p=0.977 n=12
Config Time 0.000s (±146.91%) 0.000s ~ ~ ~ p=0.478 n=12
Parse Time 0.097s (± 3.02%) 0.101s (± 4.53%) ~ 0.089s 0.112s p=0.070 n=12
Bind Time 0.037s (±10.49%) 0.036s (± 6.93%) ~ 0.028s 0.045s p=0.854 n=12
Check Time 0.825s (± 0.75%) 0.835s (± 0.59%) +0.010s (+ 1.19%) 0.821s 0.851s p=0.004 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.974s (± 0.70%) 0.987s (± 0.65%) +0.013s (+ 1.33%) 0.969s 1.003s p=0.010 n=12
vscode - native
Errors 382 382 ~ ~ ~ p=1.000 n=12
Symbols 10,141,897 10,141,897 ~ ~ ~ p=1.000 n=12
Types 3,417,826 3,417,826 ~ ~ ~ p=1.000 n=12
Memory Used 6,621,023k (± 0.01%) 6,620,556k (± 0.02%) ~ 6,617,839k 6,623,757k p=0.713 n=12
Memory Allocs 51,016,950 (± 0.01%) 51,018,703 (± 0.02%) ~ 51,006,565 51,058,824 p=0.671 n=12
Config Time 0.067s (± 0.42%) 0.067s (± 0.42%) ~ 0.067s 0.068s p=1.000 n=12
Parse Time 1.885s (± 2.79%) 1.874s (± 3.51%) ~ 1.722s 2.025s p=0.875 n=12
Bind Time 0.467s (±15.87%) 0.516s (±22.15%) ~ 0.412s 0.839s p=0.680 n=12
Check Time 13.610s (± 1.08%) 13.586s (± 1.31%) -0.024s (- 0.18%) 13.104s 13.763s p=0.043 n=12
Emit Time 4.126s (±11.01%) 4.281s (±11.97%) ~ 3.731s 5.689s p=0.541 n=12
Total Time 20.263s (± 1.74%) 20.434s (± 1.98%) ~ 19.933s 21.564s p=0.193 n=12
webpack - native
Errors 581 581 ~ ~ ~ p=1.000 n=12
Symbols 1,274,916 1,274,916 ~ ~ ~ p=1.000 n=12
Types 595,481 595,481 ~ ~ ~ p=1.000 n=12
Memory Used 972,378k (± 0.01%) 972,471k (± 0.01%) ~ 972,280k 972,636k p=0.266 n=12
Memory Allocs 6,277,155 (± 0.03%) 6,278,650 (± 0.05%) ~ 6,275,217 6,292,337 p=0.242 n=12
Config Time 0.009s 0.009s ~ ~ ~ p=1.000 n=12
Parse Time 0.291s (± 2.34%) 0.284s (± 2.33%) ~ 0.265s 0.297s p=0.147 n=12
Bind Time 0.075s (±18.61%) 0.083s (±18.12%) ~ 0.060s 0.127s p=0.766 n=12
Check Time 1.827s (± 0.62%) 1.827s (± 0.73%) ~ 1.788s 1.865s p=0.702 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.238s (± 0.64%) 2.240s (± 0.75%) ~ 2.218s 2.298s p=0.921 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,030,692 1,030,692 ~ ~ ~ p=1.000 n=12
Types 376,396 376,396 ~ ~ ~ p=1.000 n=12
Memory Used 598,426k (± 0.02%) 598,432k (± 0.01%) ~ 598,279k 598,669k p=0.944 n=12
Memory Allocs 4,762,103 (± 0.04%) 4,761,220 (± 0.03%) ~ 4,757,621 4,764,416 p=0.590 n=12
Config Time 0.003s (±13.14%) 0.003s (±10.34%) ~ 0.002s 0.003s p=0.400 n=12
Parse Time 0.144s (± 3.57%) 0.146s (± 3.91%) ~ 0.131s 0.159s p=0.384 n=12
Bind Time 0.044s (±19.10%) 0.043s (±18.91%) ~ 0.033s 0.071s p=0.697 n=12
Check Time 1.071s (± 0.86%) 1.070s (± 0.60%) ~ 1.060s 1.095s p=0.876 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.272s (± 0.92%) 1.272s (± 0.63%) ~ 1.251s 1.291s p=0.944 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
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing 792ffccb90f548cd3bdd7fc0b44f0ca9e1b169a7 and refs/pull/64558/merge:

Everything looks good!

@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 30, 2026
Merged via the queue into microsoft:main with commit edf7da4 Oct 1, 2026
29 checks passed
@jakebailey
Jake Bailey (jakebailey) deleted the fix-reverse-mapped-declarations branch October 1, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants