Skip to content

Fix a relationship check for partial generic mapped targets#62724

Closed
Andarist wants to merge 3 commits intomicrosoft:mainfrom
Andarist:fix/generic-mapped-target-fast-path
Closed

Fix a relationship check for partial generic mapped targets#62724
Andarist wants to merge 3 commits intomicrosoft:mainfrom
Andarist:fix/generic-mapped-target-fast-path

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

@Andarist Andarist commented Nov 5, 2025

Fixes #62717

const templateType = getTemplateTypeFromMappedType(target);
const modifiers = getMappedTypeModifiers(target);
if (!(modifiers & MappedTypeModifiers.ExcludeOptional)) {
const combinedOptionality = getCombinedMappedTypeOptionality(target);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is an extra fix that is not needed for the original repro. I just noticed that those 2 behaved differently: WithNumber<Partial<Record<keyof T, any>>> vs Partial<WithNumber<Record<keyof T, any>>>. So to fix that ordering difference, I included this change here

if (result = isRelatedTo(source, (nonNullComponent as IndexedAccessType).objectType, RecursionFlags.Target, reportErrors)) {
return result;
}
if (!keysRemapped && nonNullComponent.flags & TypeFlags.IndexedAccess && (nonNullComponent as IndexedAccessType).indexType === typeParameter && (result = isRelatedTo(source, (nonNullComponent as IndexedAccessType).objectType, RecursionFlags.Target, reportErrors))) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this simply allows the code to take the slow path if the fast path doesnt return Ternary.True

@RyanCavanaugh
Copy link
Copy Markdown
Member

@typescript-bot test it

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Nov 6, 2025

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-bot
Copy link
Copy Markdown
Collaborator

Hey @RyanCavanaugh, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Copy Markdown
Collaborator

@RyanCavanaugh Here are the results of running the user tests with tsc comparing main and refs/pull/62724/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Copy Markdown
Collaborator

@RyanCavanaugh
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 - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 194,506k (± 0.99%) 195,147k (± 0.92%) ~ 192,669k 196,383k p=0.230 n=6
Parse Time 1.31s (± 0.42%) 1.30s (± 0.42%) ~ 1.30s 1.31s p=1.000 n=6
Bind Time 0.72s 0.72s (± 0.71%) ~ 0.72s 0.73s p=0.174 n=6
Check Time 9.88s (± 0.46%) 9.87s (± 0.29%) ~ 9.82s 9.90s p=0.935 n=6
Emit Time 2.74s (± 0.73%) 2.76s (± 0.30%) ~ 2.75s 2.77s p=0.170 n=6
Total Time 14.65s (± 0.27%) 14.65s (± 0.16%) ~ 14.61s 14.68s p=0.625 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 956,047 956,047 ~ ~ ~ p=1.000 n=6
Types 415,881 415,883 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 1,255,052k (± 0.00%) 1,255,006k (± 0.00%) ~ 1,254,932k 1,255,066k p=0.230 n=6
Parse Time 6.55s (± 0.59%) 6.56s (± 0.72%) ~ 6.48s 6.61s p=0.573 n=6
Bind Time 1.88s (± 0.27%) 1.88s (± 0.27%) ~ 1.88s 1.89s p=1.000 n=6
Check Time 32.27s (± 0.19%) 32.24s (± 0.39%) ~ 32.08s 32.37s p=1.000 n=6
Emit Time 14.93s (± 0.20%) 14.95s (± 0.46%) ~ 14.86s 15.06s p=0.686 n=6
Total Time 55.63s (± 0.12%) 55.63s (± 0.28%) ~ 55.49s 55.90s p=0.629 n=6
mui-docs - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 552,568 552,568 ~ ~ ~ p=1.000 n=6
Types 89 89 ~ ~ ~ p=1.000 n=6
Memory used 827,086k (± 0.00%) 827,070k (± 0.00%) ~ 827,052k 827,097k p=0.093 n=6
Parse Time 8.36s (± 0.18%) 8.36s (± 0.14%) ~ 8.35s 8.38s p=0.563 n=6
Bind Time 2.19s (± 0.45%) 2.18s (± 0.47%) ~ 2.17s 2.19s p=0.386 n=6
Check Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Emit Time 0.28s 0.28s (± 1.47%) ~ 0.27s 0.28s p=0.405 n=6
Total Time 10.82s (± 0.20%) 10.82s (± 0.15%) ~ 10.80s 10.84s p=1.000 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,237,277 1,237,277 ~ ~ ~ p=1.000 n=6
Types 259,883 259,883 ~ ~ ~ p=1.000 n=6
Memory used 2,365,184k (± 0.02%) 2,486,621k (±11.94%) ~ 2,365,055k 3,093,260k p=0.378 n=6
Parse Time 5.13s (± 1.31%) 5.15s (± 1.14%) ~ 5.07s 5.20s p=0.809 n=6
Bind Time 1.77s (± 1.35%) 1.76s (± 0.95%) ~ 1.73s 1.78s p=0.720 n=6
Check Time 35.22s (± 0.12%) 35.20s (± 0.44%) ~ 35.05s 35.50s p=0.230 n=6
Emit Time 3.01s (± 1.32%) 3.02s (± 1.02%) ~ 2.99s 3.07s p=0.377 n=6
Total Time 45.15s (± 0.14%) 45.13s (± 0.40%) ~ 45.00s 45.47s p=0.336 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,237,277 1,237,277 ~ ~ ~ p=1.000 n=6
Types 259,883 259,883 ~ ~ ~ p=1.000 n=6
Memory used 3,038,991k (± 9.72%) 3,159,447k (± 0.01%) ~ 3,158,977k 3,159,837k p=0.936 n=6
Parse Time 6.80s (± 1.49%) 6.87s (± 0.33%) +0.07s (+ 1.05%) 6.84s 6.91s p=0.044 n=6
Bind Time 2.17s (± 0.86%) 2.13s (± 0.71%) -0.03s (- 1.54%) 2.11s 2.15s p=0.023 n=6
Check Time 42.81s (± 0.52%) 42.82s (± 0.18%) ~ 42.66s 42.88s p=0.575 n=6
Emit Time 3.49s (± 2.40%) 3.56s (± 2.48%) ~ 3.41s 3.66s p=0.173 n=6
Total Time 55.25s (± 0.54%) 55.38s (± 0.23%) ~ 55.19s 55.51s p=0.471 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,522 262,522 ~ ~ ~ p=1.000 n=6
Types 104,048 104,048 ~ ~ ~ p=1.000 n=6
Memory used 441,148k (± 0.25%) 440,713k (± 0.00%) ~ 440,678k 440,736k p=0.689 n=6
Parse Time 3.52s (± 0.91%) 3.51s (± 0.25%) ~ 3.50s 3.52s p=0.566 n=6
Bind Time 1.32s (± 0.89%) 1.32s (± 0.91%) ~ 1.31s 1.34s p=0.502 n=6
Check Time 18.98s (± 0.63%) 18.99s (± 0.30%) ~ 18.90s 19.07s p=0.686 n=6
Emit Time 1.52s (± 1.02%) 1.53s (± 1.37%) ~ 1.51s 1.56s p=0.460 n=6
Total Time 25.34s (± 0.63%) 25.35s (± 0.25%) ~ 25.25s 25.44s p=0.689 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,386 225,386 ~ ~ ~ p=1.000 n=6
Types 94,304 94,329 +25 (+ 0.03%) ~ ~ p=0.001 n=6
Memory used 370,120k (± 0.03%) 370,069k (± 0.06%) ~ 369,927k 370,458k p=0.230 n=6
Parse Time 2.85s (± 0.73%) 2.84s (± 0.80%) ~ 2.82s 2.88s p=0.684 n=6
Bind Time 1.60s (± 0.94%) 1.62s (± 0.64%) ~ 1.61s 1.63s p=0.078 n=6
Check Time 16.51s (± 0.37%) 16.52s (± 0.39%) ~ 16.42s 16.60s p=0.936 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 20.96s (± 0.33%) 20.98s (± 0.34%) ~ 20.92s 21.08s p=0.809 n=6
vscode - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 4,018,300 4,018,463 +163 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,260,803 1,261,056 +253 (+ 0.02%) ~ ~ p=0.001 n=6
Memory used 3,800,117k (± 0.01%) 3,800,403k (± 0.00%) ~ 3,800,227k 3,800,529k p=0.093 n=6
Parse Time 15.53s (± 0.51%) 15.58s (± 0.28%) ~ 15.51s 15.63s p=0.199 n=6
Bind Time 5.10s (± 2.40%) 5.07s (± 2.76%) ~ 4.95s 5.34s p=0.628 n=6
Check Time 104.56s (± 2.54%) 107.41s (± 3.02%) ~ 101.59s 111.45s p=0.128 n=6
Emit Time 41.42s (±14.97%) 39.90s (±16.53%) ~ 31.42s 48.44s p=0.689 n=6
Total Time 166.61s (± 2.21%) 167.96s (± 3.53%) ~ 160.52s 177.63s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 40 40 ~ ~ ~ p=1.000 n=6
Symbols 379,170 379,170 ~ ~ ~ p=1.000 n=6
Types 166,358 166,358 ~ ~ ~ p=1.000 n=6
Memory used 537,920k (± 0.04%) 537,995k (± 0.02%) ~ 537,884k 538,149k p=0.575 n=6
Parse Time 4.60s (± 0.65%) 4.62s (± 0.88%) ~ 4.56s 4.68s p=0.332 n=6
Bind Time 1.94s (± 1.37%) 1.94s (± 0.60%) ~ 1.93s 1.96s p=0.739 n=6
Check Time 22.71s (± 1.24%) 22.61s (± 0.69%) ~ 22.41s 22.82s p=0.688 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.25s (± 1.02%) 29.17s (± 0.57%) ~ 28.99s 29.43s p=0.748 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 690,485 690,485 ~ ~ ~ p=1.000 n=6
Types 208,757 208,757 ~ ~ ~ p=1.000 n=6
Memory used 586,711k (± 0.03%) 586,518k (± 0.03%) ~ 586,349k 586,694k p=0.093 n=6
Parse Time 4.17s (± 0.44%) 4.18s (± 0.73%) ~ 4.12s 4.21s p=0.459 n=6
Bind Time 1.34s (± 0.61%) 1.36s (± 0.86%) +0.02s (+ 1.62%) 1.34s 1.37s p=0.014 n=6
Check Time 20.40s (± 1.55%) 20.62s (± 1.87%) ~ 20.25s 21.01s p=0.686 n=6
Emit Time 0.00s (±154.76%) 0.01s (±109.43%) ~ 0.00s 0.01s p=0.640 n=6
Total Time 25.91s (± 1.22%) 26.17s (± 1.38%) ~ 25.82s 26.57s p=0.261 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Copy Markdown
Collaborator

@RyanCavanaugh Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62724/merge:

Everything looks good!

@russelldavis
Copy link
Copy Markdown
Contributor

@RyanCavanaugh should #62717 be reopened, given this PR?

@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Generic constraint fails with Partial<Record<keyof T, any>> but works with { [K in keyof T]?: any }

4 participants