Skip to content

Add numeric constraints to type parameters of mapped types with narrowed down array constraints #55386

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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #55383

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 15, 2023
@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 Aug 16, 2023
weswigham
weswigham previously approved these changes Sep 13, 2023
@weswigham
Copy link
Member

@typescript-bot test this
@typescript-bot run dt
@typescript-bot test top100
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2023

Heya @weswigham, I've started to run the regular perf test suite on this PR at c741755. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2023

Heya @weswigham, I've started to run the diff-based top-repos suite on this PR at c741755. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2023

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at c741755. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@weswigham
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 300,283k (± 0.01%) 300,266k (± 0.01%) ~ 300,242k 300,283k p=0.170 n=6
Parse Time 3.01s (± 0.00%) 3.01s (± 0.27%) ~ 3.00s 3.02s p=0.290 n=6
Bind Time 0.93s (± 0.44%) 0.93s (± 0.55%) ~ 0.93s 0.94s p=0.595 n=6
Check Time 9.34s (± 0.21%) 9.33s (± 0.34%) ~ 9.27s 9.36s p=0.807 n=6
Emit Time 7.64s (± 0.26%) 7.65s (± 0.38%) ~ 7.60s 7.69s p=1.000 n=6
Total Time 20.92s (± 0.15%) 20.91s (± 0.29%) ~ 20.81s 20.98s p=1.000 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,905k (± 0.03%) 194,884k (± 0.75%) ~ 193,880k 197,102k p=0.173 n=6
Parse Time 1.58s (± 0.00%) 1.58s (± 0.00%) ~ 1.58s 1.58s p=1.000 n=6
Bind Time 0.80s (± 0.51%) 0.80s (± 0.69%) ~ 0.79s 0.80s p=0.282 n=6
Check Time 9.94s (± 0.48%) 9.93s (± 0.33%) ~ 9.88s 9.97s p=0.630 n=6
Emit Time 2.73s (± 0.19%) 2.74s (± 0.20%) ~ 2.73s 2.74s p=0.640 n=6
Total Time 15.05s (± 0.30%) 15.04s (± 0.24%) ~ 14.99s 15.08s p=0.629 n=6
Monaco - node (v16.17.1, x64)
Memory used 347,178k (± 0.01%) 347,182k (± 0.01%) ~ 347,127k 347,234k p=0.688 n=6
Parse Time 2.69s (± 0.23%) 2.69s (± 0.30%) ~ 2.68s 2.70s p=0.432 n=6
Bind Time 0.99s (± 0.00%) 0.99s (± 0.00%) ~ 0.99s 0.99s p=1.000 n=6
Check Time 7.92s (± 0.10%) 7.91s (± 0.30%) ~ 7.87s 7.93s p=0.315 n=6
Emit Time 4.27s (± 0.18%) 4.26s (± 0.32%) ~ 4.25s 4.29s p=0.397 n=6
Total Time 15.87s (± 0.08%) 15.85s (± 0.25%) ~ 15.80s 15.90s p=0.291 n=6
TFS - node (v16.17.1, x64)
Memory used 301,178k (± 0.00%) 301,171k (± 0.00%) ~ 301,146k 301,184k p=0.470 n=6
Parse Time 2.18s (± 0.70%) 2.17s (± 0.61%) ~ 2.16s 2.19s p=0.800 n=6
Bind Time 1.11s (± 0.37%) 1.11s (± 0.00%) ~ 1.11s 1.11s p=0.405 n=6
Check Time 7.22s (± 0.38%) 7.24s (± 0.63%) ~ 7.19s 7.32s p=1.000 n=6
Emit Time 3.98s (± 0.27%) 3.98s (± 0.29%) ~ 3.96s 3.99s p=0.863 n=6
Total Time 14.49s (± 0.26%) 14.49s (± 0.33%) ~ 14.44s 14.57s p=1.000 n=6
material-ui - node (v16.17.1, x64)
Memory used 479,548k (± 0.00%) 479,554k (± 0.00%) ~ 479,529k 479,575k p=0.689 n=6
Parse Time 3.15s (± 0.24%) 3.15s (± 0.33%) ~ 3.13s 3.16s p=0.931 n=6
Bind Time 0.91s (± 0.00%) 0.91s (± 0.00%) ~ 0.91s 0.91s p=1.000 n=6
Check Time 17.90s (± 0.27%) 17.89s (± 0.43%) ~ 17.81s 17.98s p=1.000 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 21.95s (± 0.24%) 21.95s (± 0.37%) ~ 21.86s 22.05s p=0.936 n=6
xstate - node (v16.17.1, x64)
Memory used 542,878k (± 0.02%) 542,863k (± 0.01%) ~ 542,820k 542,947k p=1.000 n=6
Parse Time 3.68s (± 0.28%) 3.68s (± 0.20%) ~ 3.67s 3.69s p=0.931 n=6
Bind Time 1.39s (± 4.62%) 1.46s (± 0.51%) +0.07s (+ 5.03%) 1.45s 1.47s p=0.017 n=6
Check Time 3.26s (± 2.85%) 3.18s (± 0.26%) ~ 3.16s 3.18s p=0.096 n=6
Emit Time 0.08s (± 4.99%) 0.08s (± 4.99%) ~ 0.08s 0.09s p=1.000 n=6
Total Time 8.43s (± 0.45%) 8.41s (± 0.21%) ~ 8.38s 8.43s p=0.293 n=6
System info unknown
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,490ms (± 0.13%) 2,488ms (± 0.07%) ~ 2,486ms 2,491ms p=0.198 n=6
Req 2 - geterr 5,958ms (± 0.34%) 5,932ms (± 0.49%) ~ 5,897ms 5,973ms p=0.173 n=6
Req 3 - references 343ms (± 0.18%) 344ms (± 0.60%) ~ 341ms 346ms p=1.000 n=6
Req 4 - navto 276ms (± 0.77%) 276ms (± 0.87%) ~ 275ms 281ms p=0.720 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 80ms (± 3.49%) 84ms (± 7.99%) ~ 76ms 93ms p=0.293 n=6
CompilerTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,623ms (± 0.85%) 2,631ms (± 0.49%) ~ 2,612ms 2,641ms p=0.228 n=6
Req 2 - geterr 4,786ms (± 0.17%) 4,781ms (± 0.26%) ~ 4,766ms 4,799ms p=0.471 n=6
Req 3 - references 352ms (± 0.91%) 351ms (± 0.35%) ~ 349ms 352ms p=1.000 n=6
Req 4 - navto 270ms (± 1.21%) 269ms (± 0.00%) ~ 269ms 269ms p=0.655 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 79ms (± 0.95%) 79ms (± 1.60%) ~ 77ms 80ms p=0.676 n=6
xstateTSServer - node (v16.17.1, x64)
Req 1 - updateOpen 2,704ms (± 0.19%) 2,699ms (± 0.29%) ~ 2,687ms 2,711ms p=0.228 n=6
Req 2 - geterr 1,944ms (± 2.52%) 1,971ms (± 0.67%) ~ 1,947ms 1,981ms p=0.229 n=6
Req 3 - references 134ms (± 8.21%) 137ms (± 2.75%) ~ 134ms 142ms p=0.935 n=6
Req 4 - navto 359ms (± 1.01%) 359ms (± 0.57%) ~ 357ms 363ms p=0.871 n=6
Req 5 - completionInfo count 2,071 (± 0.00%) 2,071 (± 0.00%) ~ 2,071 2,071 p=1.000 n=6
Req 5 - completionInfo 322ms (± 1.86%) 325ms (± 1.66%) ~ 318ms 330ms p=0.329 n=6
System info unknown
Hosts
  • node (v16.17.1, x64)
Scenarios
  • CompilerTSServer - node (v16.17.1, x64)
  • Compiler-UnionsTSServer - node (v16.17.1, x64)
  • xstateTSServer - node (v16.17.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v16.17.1, x64)
Execution time 156.60ms (± 0.24%) 156.60ms (± 0.17%) ~ 154.48ms 159.04ms p=0.959 n=600
tsserver-startup - node (v16.17.1, x64)
Execution time 230.50ms (± 0.12%) 231.27ms (± 0.15%) +0.77ms (+ 0.33%) 229.53ms 237.28ms p=0.000 n=600
tsserverlibrary-startup - node (v16.17.1, x64)
Execution time 235.93ms (± 0.11%) 236.43ms (± 0.11%) +0.49ms (+ 0.21%) 235.18ms 238.75ms p=0.000 n=600
typescript-startup - node (v16.17.1, x64)
Execution time 236.05ms (± 0.14%) 235.95ms (± 0.11%) -0.10ms (- 0.04%) 234.91ms 238.64ms p=0.002 n=600
System info unknown
Hosts
  • node (v16.17.1, x64)
Scenarios
  • tsc-startup - node (v16.17.1, x64)
  • tsserver-startup - node (v16.17.1, x64)
  • tsserverlibrary-startup - node (v16.17.1, x64)
  • typescript-startup - node (v16.17.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@weswigham Here are the results of running the top-repos suite comparing main and refs/pull/55386/merge:

Something interesting changed - please have a look.

Details

vuejs/core

1 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

@Andarist
Copy link
Contributor Author

@jakebailey could you build a playground for this one?

@typescript-bot
Copy link
Collaborator

Hey @weswigham, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at c741755. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2023

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/157717/artifacts?artifactName=tgz&fileId=959999B2F0B57F2FA80B3158C2C39C25B9FCCADD8DC5A25DB7241C4C0169116002&fileName=/typescript-5.3.0-insiders.20230913.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/[email protected]".;

@Andarist
Copy link
Contributor Author

Got the repro case from Vue here. I will have to find time to investigate what exactly is happening here and how this could be remedied.

@sandersn
Copy link
Member

@Andarist it sounds like this PR isn't ready to merge until after it works for Vue. Did I read the history right?

@Andarist
Copy link
Contributor Author

Yes, I'll convert this to a temporary draft and ping you back when I manage to undraft it. I didn't yet have time to investigate this break.

@Andarist Andarist marked this pull request as draft November 30, 2023 16:35
@Andarist Andarist marked this pull request as ready for review July 12, 2024 21:47
@Andarist
Copy link
Contributor Author

The above change is "correct" (well, it's consistent...). This is just a new situation in which this thing can happen today: #59260

@jakebailey
Copy link
Member

@typescript-bot test it

(been a bit)

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 25, 2024

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/55386/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 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,340 62,340 ~ ~ ~ p=1.000 n=6
Types 50,378 50,378 ~ ~ ~ p=1.000 n=6
Memory used 194,485k (± 1.00%) 195,679k (± 0.75%) ~ 192,687k 196,356k p=0.378 n=6
Parse Time 1.57s (± 0.88%) 1.57s (± 0.87%) ~ 1.55s 1.59s p=0.363 n=6
Bind Time 0.86s (± 1.27%) 0.86s (± 0.95%) ~ 0.85s 0.87s p=0.448 n=6
Check Time 11.33s (± 0.38%) 11.37s (± 0.42%) ~ 11.31s 11.44s p=0.420 n=6
Emit Time 3.24s (± 0.71%) 3.24s (± 0.58%) ~ 3.22s 3.27s p=0.628 n=6
Total Time 17.00s (± 0.31%) 17.04s (± 0.24%) ~ 17.00s 17.11s p=0.224 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 7 ~ ~ ~ p=1.000 n=6
Symbols 947,102 947,102 ~ ~ ~ p=1.000 n=6
Types 410,738 410,996 +258 (+ 0.06%) ~ ~ p=0.001 n=6
Memory used 1,224,014k (± 0.00%) 1,224,125k (± 0.00%) +111k (+ 0.01%) 1,224,091k 1,224,161k p=0.005 n=6
Parse Time 7.92s (± 0.79%) 7.86s (± 0.68%) ~ 7.79s 7.90s p=0.292 n=6
Bind Time 2.24s (± 0.23%) 2.23s (± 0.44%) ~ 2.22s 2.24s p=0.417 n=6
Check Time 36.53s (± 0.32%) 36.44s (± 0.35%) ~ 36.28s 36.58s p=0.298 n=6
Emit Time 17.84s (± 0.66%) 17.91s (± 0.48%) ~ 17.79s 18.03s p=0.471 n=6
Total Time 64.52s (± 0.32%) 64.44s (± 0.25%) ~ 64.20s 64.67s p=0.378 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,521,651 2,521,651 ~ ~ ~ p=1.000 n=6
Types 936,037 936,038 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,351,796k (± 0.00%) 2,351,750k (± 0.00%) ~ 2,351,678k 2,351,793k p=0.092 n=6
Parse Time 11.00s (± 0.10%) 11.01s (± 0.32%) ~ 10.96s 11.06s p=0.743 n=6
Bind Time 2.56s (± 0.32%) 2.56s (± 0.16%) ~ 2.55s 2.56s p=0.206 n=6
Check Time 86.62s (± 0.55%) 86.64s (± 0.43%) ~ 85.91s 86.91s p=0.936 n=6
Emit Time 0.32s (± 3.05%) 0.33s (± 1.68%) ~ 0.32s 0.33s p=0.322 n=6
Total Time 100.50s (± 0.48%) 100.54s (± 0.36%) ~ 99.84s 100.80s p=0.936 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,250,061 1,250,061 ~ ~ ~ p=1.000 n=6
Types 264,970 264,970 ~ ~ ~ p=1.000 n=6
Memory used 2,404,558k (± 0.03%) 2,405,158k (± 0.04%) ~ 2,403,754k 2,406,695k p=0.230 n=6
Parse Time 6.10s (± 1.14%) 6.11s (± 1.19%) ~ 6.03s 6.19s p=1.000 n=6
Bind Time 2.27s (± 0.61%) 2.27s (± 0.79%) ~ 2.25s 2.30s p=0.935 n=6
Check Time 41.51s (± 0.70%) 41.14s (± 0.62%) -0.37s (- 0.90%) 40.96s 41.61s p=0.045 n=6
Emit Time 3.55s (± 1.30%) 3.54s (± 1.47%) ~ 3.46s 3.62s p=0.377 n=6
Total Time 53.45s (± 0.48%) 53.05s (± 0.61%) ~ 52.76s 53.63s p=0.054 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,250,061 1,250,061 ~ ~ ~ p=1.000 n=6
Types 264,970 264,970 ~ ~ ~ p=1.000 n=6
Memory used 2,478,916k (± 0.03%) 2,479,274k (± 0.03%) ~ 2,478,188k 2,480,296k p=0.471 n=6
Parse Time 7.87s (± 0.90%) 7.87s (± 1.14%) ~ 7.77s 8.02s p=0.810 n=6
Bind Time 2.53s (± 0.79%) 2.55s (± 0.73%) ~ 2.53s 2.58s p=0.090 n=6
Check Time 51.75s (± 0.63%) 51.47s (± 0.48%) ~ 51.16s 51.77s p=0.230 n=6
Emit Time 4.38s (± 1.15%) 4.36s (± 1.66%) ~ 4.24s 4.46s p=0.747 n=6
Total Time 66.53s (± 0.49%) 66.23s (± 0.43%) ~ 65.93s 66.68s p=0.128 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 260,941 260,941 ~ ~ ~ p=1.000 n=6
Types 106,385 106,385 ~ ~ ~ p=1.000 n=6
Memory used 436,632k (± 0.01%) 436,656k (± 0.01%) ~ 436,552k 436,744k p=0.378 n=6
Parse Time 4.23s (± 0.76%) 4.25s (± 1.16%) ~ 4.21s 4.34s p=0.623 n=6
Bind Time 1.61s (± 0.47%) 1.61s (± 0.47%) ~ 1.60s 1.62s p=1.000 n=6
Check Time 22.42s (± 0.38%) 22.46s (± 0.27%) ~ 22.40s 22.55s p=0.629 n=6
Emit Time 1.85s (± 1.31%) 1.84s (± 1.26%) ~ 1.82s 1.87s p=0.747 n=6
Total Time 30.11s (± 0.33%) 30.17s (± 0.18%) ~ 30.06s 30.22s p=0.374 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 68 68 ~ ~ ~ p=1.000 n=6
Symbols 225,916 225,916 ~ ~ ~ p=1.000 n=6
Types 94,414 94,414 ~ ~ ~ p=1.000 n=6
Memory used 370,915k (± 0.02%) 370,915k (± 0.02%) ~ 370,838k 371,030k p=0.936 n=6
Parse Time 3.45s (± 0.53%) 3.45s (± 0.44%) ~ 3.43s 3.46s p=0.869 n=6
Bind Time 1.92s (± 2.33%) 1.92s (± 1.08%) ~ 1.88s 1.94s p=0.871 n=6
Check Time 19.50s (± 0.47%) 19.49s (± 0.24%) ~ 19.41s 19.54s p=0.872 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.87s (± 0.43%) 24.85s (± 0.20%) ~ 24.79s 24.92s p=0.748 n=6
vscode - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 3,103,645 3,103,645 ~ ~ ~ p=1.000 n=6
Types 1,069,693 1,069,693 ~ ~ ~ p=1.000 n=6
Memory used 3,199,269k (± 0.02%) 3,198,741k (± 0.01%) ~ 3,198,030k 3,199,043k p=0.229 n=6
Parse Time 17.20s (± 0.46%) 17.24s (± 0.27%) ~ 17.17s 17.30s p=0.518 n=6
Bind Time 5.36s (± 1.69%) 5.37s (± 2.12%) ~ 5.31s 5.60s p=0.935 n=6
Check Time 100.07s (± 0.48%) 100.08s (± 0.34%) ~ 99.78s 100.70s p=0.748 n=6
Emit Time 28.88s (± 8.05%) 29.16s (± 8.12%) ~ 27.21s 32.32s p=0.689 n=6
Total Time 151.51s (± 1.45%) 151.84s (± 1.40%) ~ 149.85s 154.61s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 278,997 278,997 ~ ~ ~ p=1.000 n=6
Types 113,861 113,861 ~ ~ ~ p=1.000 n=6
Memory used 428,513k (± 0.03%) 428,528k (± 0.02%) ~ 428,437k 428,681k p=0.471 n=6
Parse Time 4.89s (± 0.28%) 4.89s (± 0.33%) ~ 4.87s 4.91s p=0.869 n=6
Bind Time 2.12s (± 1.15%) 2.12s (± 1.95%) ~ 2.08s 2.18s p=0.687 n=6
Check Time 21.89s (± 0.51%) 21.86s (± 0.45%) ~ 21.74s 22.01s p=0.573 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.91s (± 0.34%) 28.86s (± 0.45%) ~ 28.71s 29.07s p=0.422 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 540,027 540,027 ~ ~ ~ p=1.000 n=6
Types 181,292 181,296 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 483,574k (± 0.01%) 483,580k (± 0.02%) ~ 483,477k 483,725k p=0.936 n=6
Parse Time 3.24s (± 0.59%) 3.23s (± 0.75%) ~ 3.21s 3.28s p=0.569 n=6
Bind Time 1.15s (± 0.45%) 1.15s (± 0.65%) ~ 1.14s 1.16s p=0.241 n=6
Check Time 18.53s (± 0.32%) 18.58s (± 0.17%) ~ 18.54s 18.62s p=0.106 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.92s (± 0.28%) 22.96s (± 0.11%) ~ 22.91s 22.98s p=0.369 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/55386/merge:

Something interesting changed - please have a look.

Details

vuejs/core

4 of 6 projects failed to build with the old tsc and were ignored

tsconfig.json

@Andarist
Copy link
Contributor Author

The above error is the same as was reported before. I think this code was just accidentally allowed in Vue types, see my previous comment here

@@ -16633,7 +16633,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) {
const typeParameter = getHomomorphicTypeVariable(mappedType);
if (typeParameter) {
const constraint = getConstraintOfTypeParameter(typeParameter);
const constraint = getConstraintOfTypeParameter(getConditionalFlowTypeOfType(typeParameter, parent));
Copy link
Member

Choose a reason for hiding this comment

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

I will note that this call is at least a bit cursed; getConditionalFlowTypeOfType returns Type, not TypeParameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeee, this is really cursed 😬 since the result of this function was accepted as a valid type to getConstraintOfTypeParameter... I didn't really recheck what's happening here.

I'm changing this to a draft as I also noticed now that it needs extra consideration as to how it interacts with getResolvedApparentTypeOfMappedType

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not yet sure what to do about it, especially in light of #57801 that only treats mapped types ar arrays/tuples when every constituent of an intersection is array/tuple.

In this situation the constraint of the substitution type created by getConditionalFlowTypeOfType is smth like Schema & SchemaArray (so (SchemaArray | SchemaObject | LiteralType) & SchemaArray). The user's intention is clearly to treat the narrowed-down type as an array/tuple but this intersection type doesn't quite guarantee us that. Even though often an intersection like this is meant to "filter" it isn't exactly that.

I'll have to think about this one more but in the meantime I realized that there is a bug here that can be fixed separately: #60084

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: Waiting on author
Development

Successfully merging this pull request may close these issues.

Generic indexed access on a substitution type with an array constraint resolves incorrectly
5 participants