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

Fix isGenericReducibleType to allow HKT technique to function again #54112

Merged
merged 4 commits into from May 20, 2023

Conversation

ahejlsberg
Copy link
Member

Fixes #53970.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt
@typescript-bot perf test faster
@typescript-bot test top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 2023

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

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..54112

Metric main 54112 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 365,264k (± 0.01%) 365,259k (± 0.01%) ~ 365,229k 365,318k p=0.688 n=6
Parse Time 3.53s (± 0.77%) 3.55s (± 0.56%) ~ 3.52s 3.58s p=0.224 n=6
Bind Time 1.17s (± 0.44%) 1.17s (± 0.47%) ~ 1.17s 1.18s p=0.640 n=6
Check Time 9.58s (± 0.57%) 9.60s (± 0.44%) ~ 9.52s 9.63s p=0.747 n=6
Emit Time 7.92s (± 0.82%) 7.95s (± 0.80%) ~ 7.86s 8.02s p=0.335 n=6
Total Time 22.20s (± 0.55%) 22.28s (± 0.32%) ~ 22.18s 22.38s p=0.199 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,729k (± 0.05%) 192,777k (± 0.03%) ~ 192,686k 192,836k p=0.378 n=6
Parse Time 1.59s (± 0.95%) 1.59s (± 0.34%) ~ 1.59s 1.60s p=0.865 n=6
Bind Time 0.82s (± 0.00%) 0.82s (± 0.63%) ~ 0.82s 0.83s p=0.174 n=6
Check Time 10.30s (± 0.29%) 10.29s (± 0.35%) ~ 10.25s 10.35s p=0.685 n=6
Emit Time 2.99s (± 0.44%) 3.02s (± 0.93%) +0.04s (+ 1.23%) 3.00s 3.07s p=0.014 n=6
Total Time 15.71s (± 0.25%) 15.74s (± 0.38%) ~ 15.68s 15.84s p=0.331 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,841k (± 0.01%) 345,853k (± 0.01%) ~ 345,827k 345,888k p=1.000 n=6
Parse Time 2.70s (± 0.30%) 2.72s (± 0.39%) ~ 2.70s 2.73s p=0.078 n=6
Bind Time 1.08s (± 1.31%) 1.08s (± 0.38%) ~ 1.08s 1.09s p=0.858 n=6
Check Time 7.86s (± 0.53%) 7.89s (± 0.29%) ~ 7.85s 7.91s p=0.293 n=6
Emit Time 4.46s (± 0.39%) 4.47s (± 0.61%) ~ 4.45s 4.51s p=0.624 n=6
Total Time 16.11s (± 0.33%) 16.16s (± 0.32%) ~ 16.09s 16.22s p=0.102 n=6
TFS - node (v16.17.1, x64)
Memory used 300,127k (± 0.01%) 300,115k (± 0.01%) ~ 300,085k 300,132k p=0.336 n=6
Parse Time 2.15s (± 0.38%) 2.15s (± 0.42%) ~ 2.14s 2.16s p=0.550 n=6
Bind Time 1.23s (± 0.66%) 1.24s (± 0.94%) ~ 1.22s 1.25s p=0.401 n=6
Check Time 7.29s (± 0.46%) 7.29s (± 0.75%) ~ 7.22s 7.36s p=0.688 n=6
Emit Time 4.38s (± 0.55%) 4.37s (± 1.01%) ~ 4.32s 4.45s p=0.250 n=6
Total Time 15.05s (± 0.36%) 15.05s (± 0.58%) ~ 14.91s 15.16s p=1.000 n=6
material-ui - node (v16.17.1, x64)
Memory used 481,585k (± 0.01%) 481,651k (± 0.01%) +66k (+ 0.01%) 481,593k 481,712k p=0.031 n=6
Parse Time 3.24s (± 0.16%) 3.25s (± 0.23%) +0.01s (+ 0.36%) 3.24s 3.26s p=0.020 n=6
Bind Time 0.94s (± 0.55%) 0.94s (± 0.87%) ~ 0.93s 0.95s p=0.929 n=6
Check Time 17.93s (± 0.41%) 17.84s (± 0.62%) ~ 17.70s 18.03s p=0.199 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.11s (± 0.36%) 22.03s (± 0.49%) ~ 21.89s 22.21s p=0.298 n=6
xstate - node (v16.17.1, x64)
Memory used 560,337k (± 0.01%) 560,426k (± 0.02%) ~ 560,312k 560,537k p=0.298 n=6
Parse Time 3.99s (± 0.21%) 3.99s (± 0.33%) ~ 3.97s 4.01s p=0.803 n=6
Bind Time 1.76s (± 0.66%) 1.76s (± 0.59%) ~ 1.75s 1.78s p=0.619 n=6
Check Time 3.06s (± 0.55%) 3.06s (± 0.67%) ~ 3.05s 3.09s p=0.806 n=6
Emit Time 0.09s (± 4.45%) 0.09s (± 4.62%) ~ 0.08s 0.09s p=0.218 n=6
Total Time 8.90s (± 0.17%) 8.91s (± 0.24%) ~ 8.89s 8.94s p=0.368 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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 54112 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user test suite comparing main and refs/pull/54112/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 3, 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/153735/artifacts?artifactName=tgz&fileId=86B63ABAABD7BD283E61F4D0A8D4ABF9480EC038270693BC271390E9F9FBE3A202&fileName=/typescript-5.1.0-insiders.20230503.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@5.1.0-pr-54112-10".;

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

@ecyrbe
Copy link

ecyrbe commented May 3, 2023

@ahejlsberg nice, i confirm that zodios use case is working again : link to playground

@mikearnaldi
Copy link

Amazing thank you!

@mikearnaldi
Copy link

It seems that it is only partially resolved though, while inference work the signature after map(typeClass) is not resolved, that will make all the inferred types painful to use when the resulting function is not immediately applied.

Screenshot 2023-05-03 211018

@ahejlsberg ahejlsberg changed the title Improve type inference to allow HKT technique function again Fix isGenericReducibleType to allow HKT technique to function again May 5, 2023
@ahejlsberg
Copy link
Member Author

Latest commit reverts the changes to type inference and instead fixes the issue by making isGenericReducibleType more conversative. The previous logic would wrongly classify TTypeLambda & { readonly A: A; } as being reducible even though there are no discriminant properties in the type. That's now fixed.

@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt
@typescript-bot perf test faster
@typescript-bot test top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2023

Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 64a864b. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2023

Heya @ahejlsberg, I've started to run the extended test suite on this PR at 64a864b. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2023

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user test suite comparing main and refs/pull/54112/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, it looks like the DT test run failed. Please check the log for more details.
You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@jakebailey
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 5, 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/153878/artifacts?artifactName=tgz&fileId=7C2445FA53921AB59156ACC7B0E401F443E8B5A75E982249288D1530B8BAD02C02&fileName=/typescript-5.1.0-insiders.20230505.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@5.1.0-pr-54112-28".;

@mikearnaldi
Copy link

Amazing! Looks great

@jakebailey
Copy link
Member

@weswigham mentioned that this may break a case where two generic litearl kind props were intersected, but I can't seem to make this case up; can you give an example?

I've tried this to no avail. Playground Link

@jakebailey jakebailey added this to Not started in PR Backlog via automation May 8, 2023
@jakebailey jakebailey moved this from Not started to Waiting on reviewers in PR Backlog May 8, 2023
@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..54112

Metric main 54112 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 365,257k (± 0.01%) 365,263k (± 0.00%) ~ 365,246k 365,290k p=0.378 n=6
Parse Time 3.53s (± 0.58%) 3.56s (± 0.63%) ~ 3.54s 3.60s p=0.052 n=6
Bind Time 1.17s (± 0.44%) 1.17s (± 0.35%) ~ 1.17s 1.18s p=0.595 n=6
Check Time 9.57s (± 0.40%) 9.54s (± 0.29%) ~ 9.50s 9.58s p=0.226 n=6
Emit Time 7.93s (± 0.70%) 7.96s (± 0.69%) ~ 7.90s 8.04s p=0.520 n=6
Total Time 22.21s (± 0.40%) 22.23s (± 0.32%) ~ 22.13s 22.33s p=0.630 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,736k (± 0.01%) 192,776k (± 0.03%) ~ 192,686k 192,854k p=0.298 n=6
Parse Time 1.61s (± 0.55%) 1.59s (± 2.01%) ~ 1.53s 1.62s p=0.273 n=6
Bind Time 0.83s (± 0.49%) 0.83s (± 0.91%) ~ 0.82s 0.84s p=1.000 n=6
Check Time 10.27s (± 0.31%) 10.30s (± 0.62%) ~ 10.23s 10.40s p=0.372 n=6
Emit Time 3.02s (± 0.84%) 3.02s (± 0.35%) ~ 3.00s 3.03s p=1.000 n=6
Total Time 15.73s (± 0.22%) 15.74s (± 0.40%) ~ 15.67s 15.85s p=1.000 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,858k (± 0.00%) 345,869k (± 0.00%) ~ 345,857k 345,890k p=0.521 n=6
Parse Time 2.74s (± 0.54%) 2.73s (± 0.31%) ~ 2.72s 2.74s p=0.055 n=6
Bind Time 1.09s (± 0.97%) 1.09s (± 0.47%) ~ 1.08s 1.09s p=0.794 n=6
Check Time 7.86s (± 0.38%) 7.87s (± 0.30%) ~ 7.84s 7.89s p=0.684 n=6
Emit Time 4.47s (± 0.73%) 4.47s (± 0.66%) ~ 4.43s 4.50s p=1.000 n=6
Total Time 16.15s (± 0.31%) 16.15s (± 0.32%) ~ 16.09s 16.21s p=0.747 n=6
TFS - node (v16.17.1, x64)
Memory used 300,100k (± 0.01%) 300,107k (± 0.01%) ~ 300,078k 300,121k p=0.378 n=6
Parse Time 2.17s (± 0.38%) 2.16s (± 0.56%) ~ 2.14s 2.17s p=0.183 n=6
Bind Time 1.23s (± 1.30%) 1.24s (± 0.94%) ~ 1.22s 1.25s p=0.365 n=6
Check Time 7.30s (± 0.59%) 7.29s (± 0.84%) ~ 7.22s 7.38s p=0.471 n=6
Emit Time 4.41s (± 1.83%) 4.37s (± 0.78%) ~ 4.33s 4.43s p=0.244 n=6
Total Time 15.11s (± 0.57%) 15.05s (± 0.64%) ~ 14.97s 15.23s p=0.173 n=6
material-ui - node (v16.17.1, x64)
Memory used 481,578k (± 0.01%) 481,633k (± 0.01%) ~ 481,562k 481,765k p=0.173 n=6
Parse Time 3.25s (± 0.41%) 3.26s (± 0.37%) ~ 3.24s 3.27s p=0.323 n=6
Bind Time 0.94s (± 0.80%) 0.94s (± 0.55%) ~ 0.93s 0.94s p=0.784 n=6
Check Time 17.86s (± 0.67%) 17.91s (± 0.54%) ~ 17.76s 18.06s p=0.630 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.04s (± 0.55%) 22.11s (± 0.50%) ~ 21.95s 22.28s p=0.517 n=6
xstate - node (v16.17.1, x64)
Memory used 560,387k (± 0.02%) 560,457k (± 0.02%) ~ 560,349k 560,630k p=0.230 n=6
Parse Time 4.00s (± 0.29%) 4.01s (± 0.57%) ~ 3.99s 4.05s p=0.742 n=6
Bind Time 1.76s (± 0.43%) 1.76s (± 0.23%) ~ 1.76s 1.77s p=1.000 n=6
Check Time 3.07s (± 0.67%) 3.06s (± 0.29%) ~ 3.05s 3.07s p=0.215 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 0.00%) ~ 0.09s 0.09s p=1.000 n=6
Total Time 8.93s (± 0.25%) 8.92s (± 0.35%) ~ 8.88s 8.96s p=0.568 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-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 54112 6
Baseline main 6

Developer Information:

Download Benchmark

PR Backlog automation moved this from Waiting on reviewers to Needs merge May 19, 2023
@ahejlsberg ahejlsberg merged commit 1ea21e1 into main May 20, 2023
19 checks passed
PR Backlog automation moved this from Needs merge to Done May 20, 2023
@ahejlsberg ahejlsberg deleted the fix53970 branch May 20, 2023 13:36
@jakebailey
Copy link
Member

@typescript-bot cherry-pick this to release-5.1

@jakebailey
Copy link
Member

@typescript-bot cherry-pick this to release-5.1

... please?

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 22, 2023

Heya @jakebailey, I've started to run the task to cherry-pick this into release-5.1 on this PR at 64a864b. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, I've opened #54349 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request May 22, 2023
Component commits:
33aeffb Improve type inference to allow HKT technique function again

dd88229 Add regression test

f104b53 Revert changes and instead fix isGenericObjectType to be more conservative

64a864b Accept new baselines
DanielRosenwasser pushed a commit that referenced this pull request May 26, 2023
…e-5.1 (#54349)

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
PR Backlog
  
Done
Development

Successfully merging this pull request may close these issues.

Inference is broken on intersection type utilizing polymorphic this
7 participants