Skip to content

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Oct 6, 2025

fixes #62552

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Oct 6, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 6, 2025
@RyanCavanaugh
Copy link
Member

How does this affect this sample?

function id<T extends { foo : 0 | 1 }>(x: T): T {
  return x
}
const Foo = id(class {
  static readonly foo = 0
});

@Andarist
Copy link
Contributor Author

Andarist commented Oct 6, 2025

It has no effect on this sample. This one works before and after this PR. The more interesting case would be a similar one with a mutable property:

function id<T extends { foo : 0 | 1 }>(x: T): T {
  return x
}
const Foo = id(class {
  static foo = 0
});

This one errors before and after this PR as 0 widens to number. In general, the contextual typing for those static properties is very limited in inference contexts. The problem is that those properties are not checked from within the scope of checkExpressionWithContextualType so when the constraint assignability check in getInferredType does its thing the contextual type used for those static properties is any (coming from getContextualTypeForArgumentAtIndex as signature === resolvingSignature).

When there is no constraint (like in the reported issue) the class expression is checked in a deferred fashion (outside of the inference context) and then the contextual type becomes the class expression itself (coming from the already inferred and resolved signature).

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 7, 2025
@RyanCavanaugh
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 7, 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
Collaborator

typescript-bot commented Oct 7, 2025

Hey @RyanCavanaugh, 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/166262/artifacts?artifactName=tgz&fileId=B82884C27B8AD7A8182024E39A7D7192BD30C516EAAAF81B0D4567A311FE29E002&fileName=/typescript-6.0.0-insiders.20251007.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-62554-4".;

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

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

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
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 34 34 ~ ~ ~ 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 196,235k (± 0.11%) 195,208k (± 0.94%) ~ 192,824k 196,548k p=0.936 n=6
Parse Time 1.60s (± 1.66%) 1.59s (± 0.84%) ~ 1.57s 1.61s p=0.366 n=6
Bind Time 0.87s (± 0.93%) 0.88s (± 2.21%) ~ 0.86s 0.91s p=0.932 n=6
Check Time 11.74s (± 0.72%) 11.74s (± 0.64%) ~ 11.65s 11.87s p=0.936 n=6
Emit Time 3.40s (± 4.80%) 3.35s (± 4.60%) ~ 3.26s 3.66s p=0.935 n=6
Total Time 17.61s (± 1.05%) 17.55s (± 0.74%) ~ 17.40s 17.76s p=0.688 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 955,117 955,117 ~ ~ ~ p=1.000 n=6
Types 415,619 415,619 ~ ~ ~ p=1.000 n=6
Memory used 1,254,550k (± 0.00%) 1,254,556k (± 0.00%) ~ 1,254,470k 1,254,666k p=1.000 n=6
Parse Time 6.53s (± 0.76%) 6.52s (± 0.62%) ~ 6.48s 6.59s p=0.936 n=6
Bind Time 1.88s (± 0.27%) 1.88s (± 0.34%) ~ 1.87s 1.89s p=0.386 n=6
Check Time 32.14s (± 0.32%) 32.16s (± 0.51%) ~ 31.99s 32.42s p=1.000 n=6
Emit Time 14.86s (± 0.59%) 14.89s (± 0.35%) ~ 14.82s 14.96s p=0.936 n=6
Total Time 55.41s (± 0.23%) 55.45s (± 0.36%) ~ 55.26s 55.79s p=0.936 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,657,229 2,657,229 ~ ~ ~ p=1.000 n=6
Types 920,898 920,898 ~ ~ ~ p=1.000 n=6
Memory used 2,969,852k (± 0.00%) 2,969,894k (± 0.00%) ~ 2,969,844k 2,969,915k p=0.173 n=6
Parse Time 8.63s (± 0.35%) 8.65s (± 0.38%) ~ 8.60s 8.70s p=0.572 n=6
Bind Time 2.20s (± 0.47%) 2.19s (± 0.25%) ~ 2.19s 2.20s p=0.663 n=6
Check Time 90.08s (± 0.19%) 90.49s (± 0.56%) ~ 89.86s 91.17s p=0.128 n=6
Emit Time 0.30s (± 1.79%) 0.31s (± 1.68%) ~ 0.30s 0.31s p=0.640 n=6
Total Time 101.22s (± 0.17%) 101.64s (± 0.50%) ~ 101.04s 102.29s p=0.149 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,237,230 1,237,231 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 259,856 259,856 ~ ~ ~ p=1.000 n=6
Memory used 2,425,534k (± 6.12%) 2,546,594k (±11.94%) ~ 2,364,294k 3,092,754k p=0.575 n=6
Parse Time 5.13s (± 1.23%) 5.15s (± 1.69%) ~ 5.05s 5.30s p=0.936 n=6
Bind Time 1.77s (± 0.97%) 1.76s (± 0.51%) ~ 1.75s 1.77s p=0.452 n=6
Check Time 35.01s (± 0.81%) 35.04s (± 0.77%) ~ 34.67s 35.49s p=0.810 n=6
Emit Time 3.01s (± 0.94%) 3.01s (± 1.22%) ~ 2.96s 3.05s p=0.872 n=6
Total Time 44.92s (± 0.54%) 44.97s (± 0.71%) ~ 44.65s 45.58s p=0.689 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,237,230 1,237,231 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 259,856 259,856 ~ ~ ~ p=1.000 n=6
Memory used 2,431,508k (± 0.02%) 2,672,970k (±13.98%) ~ 2,431,050k 3,156,118k p=0.575 n=6
Parse Time 5.38s (± 0.20%) 5.41s (± 1.56%) ~ 5.32s 5.52s p=0.573 n=6
Bind Time 1.80s (± 1.47%) 1.79s (± 1.10%) ~ 1.77s 1.82s p=0.806 n=6
Check Time 35.09s (± 0.32%) 35.27s (± 0.71%) ~ 34.94s 35.61s p=0.173 n=6
Emit Time 3.06s (± 1.04%) 3.04s (± 0.80%) ~ 3.02s 3.09s p=0.469 n=6
Total Time 45.31s (± 0.34%) 45.52s (± 0.71%) ~ 45.15s 45.99s p=0.298 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,534 262,535 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 104,035 104,035 ~ ~ ~ p=1.000 n=6
Memory used 440,666k (± 0.01%) 440,664k (± 0.01%) ~ 440,626k 440,736k p=0.810 n=6
Parse Time 3.50s (± 0.77%) 3.52s (± 0.31%) ~ 3.50s 3.53s p=0.241 n=6
Bind Time 1.33s (± 1.30%) 1.32s (± 1.11%) ~ 1.30s 1.34s p=0.512 n=6
Check Time 19.01s (± 0.36%) 18.93s (± 0.24%) ~ 18.89s 18.98s p=0.064 n=6
Emit Time 1.54s (± 1.59%) 1.54s (± 0.90%) ~ 1.52s 1.55s p=0.935 n=6
Total Time 25.37s (± 0.33%) 25.31s (± 0.17%) ~ 25.25s 25.36s p=0.171 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 370,083k (± 0.05%) 370,144k (± 0.07%) ~ 369,911k 370,467k p=0.810 n=6
Parse Time 2.85s (± 0.96%) 2.79s (± 0.95%) -0.05s (- 1.76%) 2.76s 2.83s p=0.016 n=6
Bind Time 1.61s (± 1.47%) 1.60s (± 1.23%) ~ 1.57s 1.62s p=0.333 n=6
Check Time 16.46s (± 0.39%) 16.44s (± 0.41%) ~ 16.36s 16.54s p=0.572 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 20.92s (± 0.38%) 20.83s (± 0.33%) ~ 20.75s 20.93s p=0.092 n=6
vscode - node (v18.15.0, x64)
Errors 6 6 ~ ~ ~ p=1.000 n=6
Symbols 3,910,861 3,910,861 ~ ~ ~ p=1.000 n=6
Types 1,229,620 1,229,620 ~ ~ ~ p=1.000 n=6
Memory used 3,717,289k (± 0.00%) 3,717,151k (± 0.00%) ~ 3,716,914k 3,717,353k p=0.173 n=6
Parse Time 15.25s (± 0.77%) 15.18s (± 0.27%) ~ 15.13s 15.24s p=0.225 n=6
Bind Time 4.95s (± 0.49%) 4.95s (± 0.24%) ~ 4.94s 4.97s p=0.806 n=6
Check Time 103.56s (± 3.21%) 102.97s (± 2.49%) ~ 100.64s 107.38s p=0.689 n=6
Emit Time 31.92s (± 8.65%) 36.50s (±16.65%) 🔻+4.58s (+14.33%) 30.98s 47.27s p=0.030 n=6
Total Time 155.68s (± 2.13%) 159.60s (± 3.92%) ~ 152.08s 168.37s p=0.173 n=6
webpack - node (v18.15.0, x64)
Errors 39 39 ~ ~ ~ p=1.000 n=6
Symbols 371,242 371,242 ~ ~ ~ p=1.000 n=6
Types 162,546 162,546 ~ ~ ~ p=1.000 n=6
Memory used 526,506k (± 0.02%) 526,515k (± 0.01%) ~ 526,422k 526,611k p=0.936 n=6
Parse Time 4.45s (± 0.53%) 4.45s (± 0.77%) ~ 4.43s 4.52s p=1.000 n=6
Bind Time 1.91s (± 1.98%) 1.93s (± 1.88%) ~ 1.89s 1.97s p=0.257 n=6
Check Time 21.99s (± 0.45%) 22.02s (± 0.24%) ~ 21.95s 22.09s p=0.689 n=6
Emit Time 0.00s (±244.70%) 0.00s (±244.70%) ~ 0.00s 0.01s p=1.000 n=6
Total Time 28.34s (± 0.48%) 28.39s (± 0.22%) ~ 28.31s 28.46s p=0.423 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 673,808 673,808 ~ ~ ~ p=1.000 n=6
Types 202,123 202,123 ~ ~ ~ p=1.000 n=6
Memory used 576,322k (± 0.03%) 576,458k (± 0.03%) ~ 576,167k 576,579k p=0.298 n=6
Parse Time 4.18s (± 0.77%) 4.19s (± 0.73%) ~ 4.14s 4.22s p=0.686 n=6
Bind Time 1.34s (± 1.13%) 1.34s (± 1.21%) ~ 1.32s 1.37s p=0.934 n=6
Check Time 20.78s (± 1.62%) 20.47s (± 1.48%) ~ 20.14s 21.05s p=0.471 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 26.31s (± 1.31%) 26.01s (± 1.17%) ~ 25.68s 26.59s p=0.471 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
Collaborator

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

Everything looks good!

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: Not started
Development

Successfully merging this pull request may close these issues.

Incorrect report of self-referencing type for static fields
3 participants