Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make identity comparison reflexive across unions or intersections of the same type #60868

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MichaelMitchell-at
Copy link

Please verify that:

#60726 (comment) points out why some type testing libraries define equality with a definition like:

type Equals<A, B> = (<T>() => T extends (B & T) | T ? 1 : 0) extends (<T>() => T extends (A & T) | T ? 1 : 0) ? true : false;

rather than just

type Equals<A, B> = (<T>() => T extends B ? 1 : 0) extends (<T>() => T extends A ? 1 : 0) ? true : false;

which is that types like {a: 1} are not considered identical to types like {a: 1} & {a: 1} and {a: 1} | {a: 1}.

The latter definition of Equals is required to enable #60726, so I've made this PR to eliminate the need for the former definition of Equals.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 29, 2024
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@MichaelMitchell-at MichaelMitchell-at force-pushed the reflexive_identity_comparisons branch from 70d3914 to 7b7a9b2 Compare December 29, 2024 08:06
@MichaelMitchell-at
Copy link
Author

@jakebailey @RyanCavanaugh don't know if there's any interest in this, but mind kicking off tests?

@jakebailey
Copy link
Member

I can at least run the tests

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

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

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

Everything looks good!

@typescript-bot
Copy link
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
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 34 34 ~ ~ ~ p=1.000 n=6
Symbols 62,390 62,390 ~ ~ ~ p=1.000 n=6
Types 50,395 50,395 ~ ~ ~ p=1.000 n=6
Memory used 193,773k (± 0.75%) 193,752k (± 0.81%) ~ 193,083k 196,941k p=0.873 n=6
Parse Time 1.31s (± 0.31%) 1.31s (± 0.31%) ~ 1.31s 1.32s p=0.218 n=6
Bind Time 0.73s 0.73s ~ ~ ~ p=1.000 n=6
Check Time 9.80s (± 0.27%) 9.85s (± 0.31%) ~ 9.81s 9.88s p=0.053 n=6
Emit Time 2.73s (± 0.49%) 2.74s (± 0.71%) ~ 2.71s 2.77s p=0.285 n=6
Total Time 14.57s (± 0.17%) 14.62s (± 0.23%) +0.05s (+ 0.38%) 14.57s 14.66s p=0.024 n=6
angular-1 - node (v18.15.0, x64)
Errors 37 37 ~ ~ ~ p=1.000 n=6
Symbols 947,969 947,969 ~ ~ ~ p=1.000 n=6
Types 410,955 410,955 ~ ~ ~ p=1.000 n=6
Memory used 1,225,674k (± 0.00%) 1,226,786k (± 0.00%) +1,113k (+ 0.09%) 1,226,726k 1,226,828k p=0.005 n=6
Parse Time 6.65s (± 0.91%) 6.59s (± 0.50%) ~ 6.56s 6.65s p=0.106 n=6
Bind Time 1.90s (± 0.54%) 1.91s (± 0.29%) ~ 1.90s 1.91s p=0.138 n=6
Check Time 32.07s (± 0.38%) 32.07s (± 0.34%) ~ 31.94s 32.19s p=1.000 n=6
Emit Time 15.23s (± 0.35%) 15.14s (± 0.54%) -0.10s (- 0.63%) 14.98s 15.22s p=0.016 n=6
Total Time 55.85s (± 0.33%) 55.70s (± 0.27%) ~ 55.47s 55.86s p=0.199 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,445,991 2,446,011 +20 (+ 0.00%) ~ ~ p=0.001 n=6
Types 896,571 896,574 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,309,673k (± 0.00%) 2,309,777k (± 0.00%) +104k (+ 0.00%) 2,309,700k 2,309,818k p=0.008 n=6
Parse Time 8.91s (± 0.27%) 8.94s (± 0.41%) ~ 8.90s 8.99s p=0.361 n=6
Bind Time 2.13s (± 0.49%) 2.12s (± 0.76%) ~ 2.10s 2.14s p=0.510 n=6
Check Time 73.24s (± 0.36%) 73.39s (± 0.49%) ~ 72.87s 73.95s p=0.575 n=6
Emit Time 0.28s (± 2.88%) 0.28s (± 3.19%) ~ 0.27s 0.29s p=0.550 n=6
Total Time 84.55s (± 0.32%) 84.73s (± 0.43%) ~ 84.21s 85.30s p=0.521 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,228,377 1,228,452 +75 (+ 0.01%) ~ ~ p=0.001 n=6
Types 266,839 266,850 +11 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,359,941k (± 0.02%) 2,360,079k (± 0.02%) ~ 2,359,325k 2,360,876k p=0.575 n=6
Parse Time 5.17s (± 0.59%) 5.21s (± 1.15%) ~ 5.14s 5.30s p=0.470 n=6
Bind Time 1.77s (± 1.11%) 1.78s (± 1.48%) ~ 1.75s 1.82s p=0.870 n=6
Check Time 35.17s (± 0.22%) 35.34s (± 0.33%) +0.17s (+ 0.48%) 35.21s 35.54s p=0.020 n=6
Emit Time 2.99s (± 1.77%) 2.99s (± 0.98%) ~ 2.96s 3.04s p=0.936 n=6
Total Time 45.12s (± 0.27%) 45.32s (± 0.29%) +0.20s (+ 0.44%) 45.18s 45.49s p=0.031 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,228,377 1,228,452 +75 (+ 0.01%) ~ ~ p=0.001 n=6
Types 266,839 266,850 +11 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,035,607k (± 9.76%) 3,036,343k (± 9.75%) ~ 2,431,398k 3,158,150k p=0.173 n=6
Parse Time 6.95s (± 1.64%) 7.01s (± 0.77%) ~ 6.95s 7.07s p=0.689 n=6
Bind Time 2.14s (± 2.16%) 2.11s (± 1.10%) ~ 2.08s 2.14s p=0.521 n=6
Check Time 42.90s (± 0.52%) 42.96s (± 0.19%) ~ 42.85s 43.09s p=0.470 n=6
Emit Time 3.50s (± 1.53%) 3.48s (± 1.83%) ~ 3.41s 3.58s p=0.689 n=6
Total Time 55.48s (± 0.59%) 55.57s (± 0.24%) ~ 55.43s 55.73s p=1.000 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,624 262,697 +73 (+ 0.03%) ~ ~ p=0.001 n=6
Types 106,695 106,706 +11 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 440,803k (± 0.02%) 440,842k (± 0.01%) ~ 440,755k 440,886k p=0.689 n=6
Parse Time 3.54s (± 0.46%) 3.56s (± 0.72%) ~ 3.53s 3.60s p=0.222 n=6
Bind Time 1.33s (± 0.56%) 1.33s (± 0.48%) ~ 1.32s 1.34s p=0.718 n=6
Check Time 19.01s (± 0.29%) 19.14s (± 0.39%) +0.13s (+ 0.69%) 19.01s 19.22s p=0.029 n=6
Emit Time 1.54s (± 1.09%) 1.54s (± 0.86%) ~ 1.52s 1.55s p=0.869 n=6
Total Time 25.43s (± 0.18%) 25.58s (± 0.26%) +0.15s (+ 0.59%) 25.46s 25.65s p=0.013 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 70 70 ~ ~ ~ p=1.000 n=6
Symbols 226,095 226,095 ~ ~ ~ p=1.000 n=6
Types 94,488 94,488 ~ ~ ~ p=1.000 n=6
Memory used 371,672k (± 0.01%) 371,748k (± 0.04%) ~ 371,649k 372,046k p=0.575 n=6
Parse Time 2.90s (± 1.19%) 2.91s (± 0.68%) ~ 2.87s 2.92s p=0.627 n=6
Bind Time 1.60s (± 1.21%) 1.61s (± 1.07%) ~ 1.58s 1.63s p=0.254 n=6
Check Time 16.46s (± 0.15%) 16.54s (± 0.44%) ~ 16.40s 16.60s p=0.065 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.96s (± 0.21%) 21.05s (± 0.38%) +0.10s (+ 0.46%) 20.91s 21.13s p=0.045 n=6
vscode - node (v18.15.0, x64)
Errors 3 3 ~ ~ ~ p=1.000 n=6
Symbols 3,239,020 3,239,020 ~ ~ ~ p=1.000 n=6
Types 1,115,422 1,115,422 ~ ~ ~ p=1.000 n=6
Memory used 3,306,754k (± 0.01%) 3,306,672k (± 0.00%) ~ 3,306,418k 3,306,810k p=0.378 n=6
Parse Time 14.19s (± 0.76%) 14.19s (± 0.59%) ~ 14.09s 14.31s p=0.936 n=6
Bind Time 4.64s (± 2.81%) 4.55s (± 0.26%) ~ 4.54s 4.57s p=0.139 n=6
Check Time 87.97s (± 1.58%) 87.92s (± 1.34%) ~ 86.91s 90.22s p=0.810 n=6
Emit Time 27.89s (± 2.05%) 28.00s (± 2.82%) ~ 27.39s 29.57s p=0.873 n=6
Total Time 134.69s (± 1.15%) 134.66s (± 1.03%) ~ 133.15s 136.65s p=0.575 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 291,595 291,595 ~ ~ ~ p=1.000 n=6
Types 118,971 118,971 ~ ~ ~ p=1.000 n=6
Memory used 445,342k (± 0.02%) 445,322k (± 0.03%) ~ 445,142k 445,518k p=0.936 n=6
Parse Time 5.08s (± 1.17%) 5.10s (± 0.63%) ~ 5.05s 5.15s p=0.333 n=6
Bind Time 2.22s (± 0.66%) 2.20s (± 1.28%) ~ 2.15s 2.23s p=0.145 n=6
Check Time 23.36s (± 0.46%) 23.61s (± 2.24%) ~ 23.23s 24.67s p=0.261 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 30.66s (± 0.26%) 30.92s (± 1.67%) ~ 30.59s 31.95s p=0.378 n=6
xstate-main - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 555,050 555,112 +62 (+ 0.01%) ~ ~ p=0.001 n=6
Types 186,115 186,131 +16 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 494,021k (± 0.01%) 494,102k (± 0.01%) ~ 494,030k 494,206k p=0.066 n=6
Parse Time 3.40s (± 0.86%) 3.42s (± 0.48%) ~ 3.39s 3.44s p=0.224 n=6
Bind Time 1.19s (± 0.92%) 1.19s (± 1.37%) ~ 1.16s 1.21s p=0.931 n=6
Check Time 19.55s (± 0.24%) 19.66s (± 0.46%) +0.11s (+ 0.55%) 19.52s 19.77s p=0.045 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.15s (± 0.25%) 24.26s (± 0.40%) +0.12s (+ 0.48%) 24.10s 24.36s p=0.045 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

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

Everything looks good!

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

Successfully merging this pull request may close these issues.

3 participants