TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Fix `isGenericReducibleType` to allow HKT technique to function again

Open ahejlsberg opened this issue 1 year ago • 30 comments

Fixes #53970.

ahejlsberg avatar May 03 '23 15:05 ahejlsberg

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

ahejlsberg avatar May 03 '23 15:05 ahejlsberg

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

Update: The results are in!

typescript-bot avatar May 03 '23 15:05 typescript-bot

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

Update: The results are in!

typescript-bot avatar May 03 '23 15:05 typescript-bot

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

Update: The results are in!

typescript-bot avatar May 03 '23 15:05 typescript-bot

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

Update: The results are in!

typescript-bot avatar May 03 '23 15:05 typescript-bot

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

typescript-bot avatar May 03 '23 15:05 typescript-bot

@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 avatar May 03 '23 15:05 typescript-bot

@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 avatar May 03 '23 16:05 typescript-bot

@typescript-bot pack this

jakebailey avatar May 03 '23 16:05 jakebailey

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

typescript-bot avatar May 03 '23 16:05 typescript-bot

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/[email protected]".;

typescript-bot avatar May 03 '23 16:05 typescript-bot

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

Everything looks good!

typescript-bot avatar May 03 '23 17:05 typescript-bot

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

typescript-bot avatar May 03 '23 17:05 typescript-bot

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

ecyrbe avatar May 03 '23 19:05 ecyrbe

Amazing thank you!

mikearnaldi avatar May 03 '23 20:05 mikearnaldi

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

mikearnaldi avatar May 03 '23 20:05 mikearnaldi

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 avatar May 05 '23 00:05 ahejlsberg

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

ahejlsberg avatar May 05 '23 00:05 ahejlsberg

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

Update: The results are in!

typescript-bot avatar May 05 '23 00:05 typescript-bot

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

typescript-bot avatar May 05 '23 00:05 typescript-bot

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

Update: The results are in!

typescript-bot avatar May 05 '23 00:05 typescript-bot

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

Update: The results are in!

typescript-bot avatar May 05 '23 00:05 typescript-bot

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

Update: The results are in!

typescript-bot avatar May 05 '23 00:05 typescript-bot

@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 avatar May 05 '23 00:05 typescript-bot

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 avatar May 05 '23 02:05 typescript-bot

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

Everything looks good!

typescript-bot avatar May 05 '23 02:05 typescript-bot

@typescript-bot pack this

jakebailey avatar May 05 '23 05:05 jakebailey

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

typescript-bot avatar May 05 '23 05:05 typescript-bot

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/[email protected]".;

typescript-bot avatar May 05 '23 05:05 typescript-bot

Amazing! Looks great

mikearnaldi avatar May 05 '23 09:05 mikearnaldi