Skip to content

Don't defer index types for non-generic substitution types#61999

Closed
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/dont-defer-index-types-on-non-generic-substitutions
Closed

Don't defer index types for non-generic substitution types#61999
Andarist wants to merge 1 commit intomicrosoft:mainfrom
Andarist:fix/dont-defer-index-types-on-non-generic-substitutions

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

@Andarist Andarist commented Jul 6, 2025

fixes #61728

Copilot AI review requested due to automatic review settings July 6, 2025 12:12
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jul 6, 2025
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug labels Jul 6, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that index types on non-generic substitution types are resolved immediately (instead of deferred), addressing #61728.

  • Added two new compiler tests to verify index lookups on non-generic substitution types.
  • Modified getIndexType in checker.ts to bypass deferral when both baseType and constraint are non-generic.

Reviewed Changes

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

File Description
tests/cases/compiler/substitutionTypeNonGenericIndexType1.ts Adds a test for boolean conditional index resolution on non-generic substitution types.
tests/cases/compiler/substitutionTypeNonGenericIndexType2.ts Adds a test for infer-based index resolution on non-generic substitution types.
src/compiler/checker.ts Updates getIndexType to immediately compute index types for non-generic substitutions.
Comments suppressed due to low confidence (3)

tests/cases/compiler/substitutionTypeNonGenericIndexType2.ts:1

  • [nitpick] Consider adding a reference to GitHub issue #61728 at the top of this test for consistency with related test files.
// @strict: true

tests/cases/compiler/substitutionTypeNonGenericIndexType2.ts:14

  • [nitpick] Consider adding additional test cases where either the baseType or the constraint is generic to ensure this new index type logic covers mixed generic scenarios.
const test: Test["rejectClose"] = "rejectClose";

@jakebailey
Copy link
Copy Markdown
Member

@typescript-bot test it
@typescript-bot pack this

@typescript-bot
Copy link
Copy Markdown
Collaborator

typescript-bot commented Dec 4, 2025

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

Command Status Results
pack this ✅ Started ✅ 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

typescript-bot commented Dec 4, 2025

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/166679/artifacts?artifactName=tgz&fileId=88C40553CBD26DF9E98DFD51DFBA9C2A38B2C0583A8FB0F8359BAF58E5856DDD02&fileName=/typescript-6.0.0-insiders.20251204.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@6.0.0-pr-61999-2".;

@typescript-bot
Copy link
Copy Markdown
Collaborator

Hey @jakebailey, 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

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/61999/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

@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 - 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,387 50,387 ~ ~ ~ p=1.000 n=6
Memory used 195,063k (± 0.97%) 192,710k (± 0.10%) ~ 192,602k 193,076k p=0.092 n=6
Parse Time 1.30s (± 0.69%) 1.30s (± 0.58%) ~ 1.29s 1.31s p=0.798 n=6
Bind Time 0.75s (± 0.54%) 0.75s ~ ~ ~ p=0.405 n=6
Check Time 9.89s (± 0.18%) 9.89s (± 0.52%) ~ 9.84s 9.97s p=0.748 n=6
Emit Time 2.74s (± 0.63%) 2.73s (± 0.56%) ~ 2.70s 2.74s p=0.323 n=6
Total Time 14.68s (± 0.17%) 14.67s (± 0.37%) ~ 14.62s 14.74s p=0.572 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 956,048 956,048 ~ ~ ~ p=1.000 n=6
Types 415,904 415,904 ~ ~ ~ p=1.000 n=6
Memory used 1,255,277k (± 0.00%) 1,255,251k (± 0.01%) ~ 1,255,190k 1,255,353k p=0.230 n=6
Parse Time 7.99s (± 0.73%) 8.01s (± 0.97%) ~ 7.94s 8.13s p=0.574 n=6
Bind Time 2.37s (± 0.83%) 2.36s (± 0.32%) ~ 2.35s 2.37s p=0.405 n=6
Check Time 38.74s (± 0.19%) 38.89s (± 0.24%) +0.15s (+ 0.39%) 38.74s 38.98s p=0.037 n=6
Emit Time 17.94s (± 0.50%) 17.93s (± 0.49%) ~ 17.81s 18.03s p=0.809 n=6
Total Time 67.05s (± 0.13%) 67.18s (± 0.23%) ~ 66.90s 67.37s p=0.128 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,722,106 2,722,106 ~ ~ ~ p=1.000 n=6
Types 937,535 937,535 ~ ~ ~ p=1.000 n=6
Memory used 3,050,995k (± 0.00%) 3,050,980k (± 0.00%) ~ 3,050,893k 3,051,084k p=0.936 n=6
Parse Time 8.54s (± 0.17%) 8.54s (± 0.18%) ~ 8.52s 8.55s p=0.933 n=6
Bind Time 2.32s (± 0.70%) 2.32s (± 0.57%) ~ 2.30s 2.33s p=0.869 n=6
Check Time 93.05s (± 0.39%) 93.06s (± 0.71%) ~ 92.51s 94.20s p=0.873 n=6
Emit Time 0.31s (± 3.15%) 0.31s (± 2.44%) ~ 0.30s 0.32s p=0.652 n=6
Total Time 104.23s (± 0.36%) 104.24s (± 0.62%) ~ 103.71s 105.33s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,251,654 1,251,654 ~ ~ ~ p=1.000 n=6
Types 259,840 259,840 ~ ~ ~ p=1.000 n=6
Memory used 2,392,908k (± 0.03%) 2,574,802k (±11.82%) ~ 2,392,575k 3,121,215k p=0.173 n=6
Parse Time 5.19s (± 0.80%) 5.21s (± 1.54%) ~ 5.12s 5.32s p=0.630 n=6
Bind Time 1.82s (± 0.22%) 1.82s (± 1.59%) ~ 1.77s 1.85s p=0.608 n=6
Check Time 35.49s (± 0.28%) 35.46s (± 0.96%) ~ 34.90s 35.94s p=1.000 n=6
Emit Time 2.99s (± 2.45%) 3.02s (± 1.49%) ~ 2.98s 3.09s p=0.689 n=6
Total Time 45.51s (± 0.14%) 45.53s (± 0.68%) ~ 45.12s 46.03s p=1.000 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,251,654 1,251,654 ~ ~ ~ p=1.000 n=6
Types 259,840 259,840 ~ ~ ~ p=1.000 n=6
Memory used 2,459,526k (± 0.02%) 2,459,616k (± 0.02%) ~ 2,458,812k 2,460,216k p=0.689 n=6
Parse Time 5.33s (± 0.84%) 5.34s (± 0.40%) ~ 5.31s 5.37s p=0.747 n=6
Bind Time 1.87s (± 1.04%) 1.86s (± 0.22%) ~ 1.85s 1.86s p=0.210 n=6
Check Time 35.59s (± 0.57%) 35.53s (± 0.29%) ~ 35.38s 35.68s p=0.575 n=6
Emit Time 3.07s (± 0.73%) 3.07s (± 1.59%) ~ 3.01s 3.15s p=0.873 n=6
Total Time 45.86s (± 0.50%) 45.82s (± 0.23%) ~ 45.68s 45.96s p=0.689 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 264,287 264,287 ~ ~ ~ p=1.000 n=6
Types 104,051 104,051 ~ ~ ~ p=1.000 n=6
Memory used 443,264k (± 0.01%) 443,310k (± 0.01%) ~ 443,248k 443,353k p=0.128 n=6
Parse Time 3.52s (± 1.09%) 3.53s (± 0.77%) ~ 3.50s 3.57s p=0.466 n=6
Bind Time 1.40s (± 1.11%) 1.38s (± 0.54%) -0.02s (- 1.31%) 1.37s 1.39s p=0.015 n=6
Check Time 19.23s (± 0.55%) 19.19s (± 0.40%) ~ 19.12s 19.28s p=0.419 n=6
Emit Time 1.53s (± 1.01%) 1.54s (± 0.82%) ~ 1.53s 1.56s p=0.328 n=6
Total Time 25.68s (± 0.50%) 25.65s (± 0.41%) ~ 25.53s 25.76s p=0.810 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,493 225,493 ~ ~ ~ p=1.000 n=6
Types 94,373 94,373 ~ ~ ~ p=1.000 n=6
Memory used 370,150k (± 0.02%) 370,304k (± 0.07%) ~ 370,061k 370,595k p=0.689 n=6
Parse Time 2.84s (± 1.73%) 2.82s (± 0.86%) ~ 2.80s 2.86s p=0.627 n=6
Bind Time 1.64s (± 1.09%) 1.64s (± 1.26%) ~ 1.63s 1.67s p=0.931 n=6
Check Time 16.59s (± 0.41%) 16.60s (± 0.43%) ~ 16.50s 16.69s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 21.07s (± 0.37%) 21.07s (± 0.29%) ~ 20.99s 21.15s p=0.871 n=6
vscode - node (v18.15.0, x64)
Errors 11 11 ~ ~ ~ p=1.000 n=6
Symbols 4,076,919 4,076,919 ~ ~ ~ p=1.000 n=6
Types 1,284,323 1,284,323 ~ ~ ~ p=1.000 n=6
Memory used 3,862,422k (± 0.00%) 3,862,556k (± 0.00%) +134k (+ 0.00%) 3,862,445k 3,862,722k p=0.020 n=6
Parse Time 15.62s (± 0.76%) 15.66s (± 0.79%) ~ 15.53s 15.86s p=0.748 n=6
Bind Time 5.24s (± 0.79%) 5.25s (± 1.31%) ~ 5.20s 5.38s p=0.748 n=6
Check Time 113.90s (± 2.73%) 113.27s (± 2.88%) ~ 109.85s 118.60s p=0.575 n=6
Emit Time 40.80s (±14.01%) 41.39s (± 7.53%) ~ 38.43s 45.48s p=0.575 n=6
Total Time 175.56s (± 4.99%) 175.58s (± 3.35%) ~ 169.44s 182.56s p=0.936 n=6
webpack - node (v18.15.0, x64)
Errors 40 40 ~ ~ ~ p=1.000 n=6
Symbols 380,758 380,758 ~ ~ ~ p=1.000 n=6
Types 166,811 166,811 ~ ~ ~ p=1.000 n=6
Memory used 540,886k (± 0.02%) 540,864k (± 0.02%) ~ 540,779k 541,004k p=0.689 n=6
Parse Time 4.72s (± 0.69%) 4.73s (± 0.56%) ~ 4.70s 4.77s p=0.808 n=6
Bind Time 2.02s (± 1.24%) 2.03s (± 0.91%) ~ 2.02s 2.07s p=0.404 n=6
Check Time 23.02s (± 0.68%) 22.99s (± 0.41%) ~ 22.85s 23.13s p=0.574 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.77s (± 0.60%) 29.75s (± 0.28%) ~ 29.64s 29.86s p=0.688 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 692,951 692,951 ~ ~ ~ p=1.000 n=6
Types 210,425 210,425 ~ ~ ~ p=1.000 n=6
Memory used 589,064k (± 0.01%) 588,971k (± 0.03%) ~ 588,802k 589,124k p=0.471 n=6
Parse Time 4.17s (± 0.82%) 4.15s (± 0.47%) ~ 4.13s 4.18s p=0.331 n=6
Bind Time 1.39s (± 1.24%) 1.41s (± 1.10%) ~ 1.39s 1.43s p=0.086 n=6
Check Time 20.83s (± 1.38%) 21.10s (± 2.01%) ~ 20.67s 21.52s p=0.228 n=6
Emit Time 0.01s (±77.38%) 0.00s 🟩-0.01s (-100.00%) ~ ~ p=0.025 n=6
Total Time 26.39s (± 1.16%) 26.68s (± 1.68%) ~ 26.21s 27.12s p=0.298 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

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

Everything looks good!

@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 Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Poor quick info due to erroneously deferring keyof T since #51621

5 participants