Skip to content

Defer conditional types with multi-element tuple types in extends clause - #52091

Merged
Anders Hejlsberg (ahejlsberg) merged 3 commits into
mainfrom
fix52068
Jan 6, 2023
Merged

Anders Hejlsberg (ahejlsberg) merged 3 commits into
mainfrom
fix52068

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #52068.

@ahejlsberg

Copy link
Copy Markdown
Member Author

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 4, 2023 •

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at e9f81ce. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 4, 2023 •

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based user code test suite on this PR at e9f81ce. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 4, 2023 •

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at e9f81ce. You can monitor the build here.

Update: The results are in!

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 4, 2023 •

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based top-repos suite on this PR at e9f81ce. You can monitor the build here.

@typescript-bot

TypeScript Bot (typescript-bot) commented Jan 4, 2023 •

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at e9f81ce. You can monitor the build here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg) Here are the results of running the user test suite comparing main and refs/pull/52091/merge:

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Heya Anders Hejlsberg (@ahejlsberg), I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Anders Hejlsberg (@ahejlsberg)
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..52091

Metric main 52091 Delta Best Worst
Angular - node (v16.17.1, x64)
Memory used 371,830k (± 0.01%) 371,857k (± 0.01%) +27k (+ 0.01%) 371,793k 371,900k
Parse Time 4.16s (± 0.72%) 4.14s (± 0.41%) -0.02s (- 0.55%) 4.12s 4.16s
Bind Time 1.27s (± 0.39%) 1.27s (± 0.63%) -0.00s (- 0.07%) 1.26s 1.28s
Check Time 9.32s (± 0.64%) 9.29s (± 0.68%) -0.03s (- 0.33%) 9.23s 9.41s
Emit Time 8.00s (± 0.64%) 7.98s (± 0.35%) -0.03s (- 0.32%) 7.95s 8.02s
Total Time 22.76s (± 0.42%) 22.68s (± 0.39%) -0.08s (- 0.36%) 22.57s 22.82s
Compiler-Unions - node (v16.17.1, x64)
Memory used 199,864k (± 0.03%) 200,353k (± 0.69%) +489k (+ 0.24%) 199,422k 203,132k
Parse Time 1.80s (± 0.74%) 1.82s (± 0.56%) +0.02s (+ 0.91%) 1.80s 1.83s
Bind Time 0.84s (± 0.54%) 0.84s (± 0.74%) -0.00s (- 0.40%) 0.83s 0.85s
Check Time 10.05s (± 0.87%) 10.15s (± 0.86%) +0.10s (+ 1.02%) 10.00s 10.23s
Emit Time 2.99s (± 1.96%) 3.04s (± 4.86%) +0.05s (+ 1.58%) 2.94s 3.34s
Total Time 15.68s (± 0.77%) 15.85s (± 1.21%) +0.17s (+ 1.06%) 15.66s 16.20s
Monaco - node (v16.17.1, x64)
Memory used 353,272k (± 0.01%) 353,277k (± 0.01%) +5k (+ 0.00%) 353,239k 353,347k
Parse Time 3.18s (± 0.84%) 3.17s (± 0.43%) -0.00s (- 0.08%) 3.16s 3.19s
Bind Time 1.12s (± 0.88%) 1.11s (± 1.07%) -0.01s (- 1.32%) 1.10s 1.13s
Check Time 7.87s (± 0.66%) 7.84s (± 0.56%) -0.03s (- 0.37%) 7.79s 7.90s
Emit Time 4.49s (± 0.69%) 4.46s (± 0.28%) -0.03s (- 0.58%) 4.45s 4.48s
Total Time 16.66s (± 0.54%) 16.58s (± 0.24%) -0.08s (- 0.45%) 16.51s 16.63s
TFS - node (v16.17.1, x64)
Memory used 309,221k (± 0.00%) 309,214k (± 0.00%) -7k (- 0.00%) 309,203k 309,238k
Parse Time 2.57s (± 2.25%) 2.63s (± 1.96%) +0.06s (+ 2.29%) 2.58s 2.72s
Bind Time 1.09s (± 7.67%) 1.07s (± 1.25%) -0.02s (- 1.92%) 1.05s 1.09s
Check Time 7.41s (± 0.54%) 7.38s (± 0.64%) -0.03s (- 0.35%) 7.31s 7.45s
Emit Time 4.22s (± 0.53%) 4.23s (± 0.77%) +0.01s (+ 0.29%) 4.19s 4.27s
Total Time 15.28s (± 0.32%) 15.31s (± 0.38%) +0.02s (+ 0.16%) 15.26s 15.42s
material-ui - node (v16.17.1, x64)
Memory used 484,359k (± 0.00%) 484,356k (± 0.01%) -3k (- 0.00%) 484,318k 484,395k
Parse Time 3.68s (± 0.46%) 3.67s (± 0.44%) -0.00s (- 0.13%) 3.66s 3.70s
Bind Time 1.01s (± 1.00%) 1.01s (± 0.54%) -0.01s (- 0.59%) 1.00s 1.01s
Check Time 17.96s (± 0.82%) 17.91s (± 0.66%) -0.05s (- 0.28%) 17.79s 18.14s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 22.66s (± 0.73%) 22.59s (± 0.54%) -0.06s (- 0.27%) 22.45s 22.81s
xstate - node (v16.17.1, x64)
Memory used 567,302k (± 0.00%) 567,330k (± 0.01%) +28k (+ 0.00%) 567,295k 567,439k
Parse Time 4.74s (± 0.62%) 4.77s (± 0.47%) +0.03s (+ 0.59%) 4.75s 4.80s
Bind Time 1.64s (± 0.47%) 1.66s (± 0.59%) +0.01s (+ 0.87%) 1.65s 1.67s
Check Time 2.83s (± 0.36%) 2.84s (± 0.28%) +0.01s (+ 0.18%) 2.83s 2.84s
Emit Time 0.08s (± 6.58%) 0.09s (± 6.05%) +0.00s (+ 2.03%) 0.08s 0.09s
Total Time 9.31s (± 0.38%) 9.35s (± 0.33%) +0.05s (+ 0.53%) 9.32s 9.40s
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
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 52091 6
Baseline main 6

Developer Information:

Download Benchmark

duanwilliam added a commit to owonomicon/ts that referenced this pull request Jan 4, 2023
… types

as of TS4.9, conditional types are only deferred for single-element tuples, not multi-element ones.
this should be fixed in microsoft/TypeScript#52091, slated for the TS5.0 milestone.
until then, however, the implementations of `MutuallyAssignable`, `And`, and `Xor` can be assumed to be bugged.
this commit fixes them to properly defer types.
`Or` was also like this but fixed in earlier commit 0cd75d4

@weswigham Wesley Wigham (weswigham) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't want to think of a way to expand this to cover, eg {x: X} extends {x: Y} and similar ilk, right?

@ahejlsberg

Copy link
Copy Markdown
Member Author

Wesley Wigham (@weswigham) Would be nice to do so, but requires more thinking about permissive/restrictive instantiations and/or some sort of "possibly assignable to" relation. I'm chewing on that, but nothing concrete yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected type evaluation with generic conditional type

4 participants