-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Mark conditional extends as Unmeasurable and use a conditional-opaque wildcard for type erasure #43887
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
Conversation
… wildcard for type erasure
@typescript-bot pack this |
Heya @weswigham, I've started to run the parallelized community code test suite on this PR at fda479e. You can monitor the build here. |
Heya @weswigham, I've started to run the extended test suite on this PR at fda479e. You can monitor the build here. |
Heya @weswigham, I've started to run the perf test suite on this PR at fda479e. You can monitor the build here. Update: The results are in! |
Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at fda479e. You can monitor the build here. |
Heya @weswigham, I've started to run the tarball bundle task on this PR at fda479e. You can monitor the build here. |
Hey @weswigham, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
@weswigham Here they are:Comparison Report - master..43887
System
Hosts
Scenarios
Developer Information: |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@@ -13788,7 +13791,10 @@ namespace ts { | |||
const includes = addTypesToUnion(typeSet, 0, types); | |||
if (unionReduction !== UnionReduction.None) { | |||
if (includes & TypeFlags.AnyOrUnknown) { | |||
return includes & TypeFlags.Any ? includes & TypeFlags.IncludesWildcard ? wildcardType : anyType : unknownType; | |||
// A wildcard has the _lowest_ type id, as it's first types created, and it's made in priority order | |||
// - a normal `wildcardType` should take priority over an `opaqueWildcardType` if both somehoe end up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
somehow* end up
@@ -13629,7 +13632,7 @@ namespace ts { | |||
if (!(flags & TypeFlags.Never)) { | |||
includes |= flags & TypeFlags.IncludesMask; | |||
if (flags & TypeFlags.StructuredOrInstantiable) includes |= TypeFlags.IncludesStructuredOrInstantiable; | |||
if (type === wildcardType) includes |= TypeFlags.IncludesWildcard; | |||
if (type === wildcardType || type === opaqueWildcardType) includes |= TypeFlags.IncludesWildcard; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also set the IncludesOpaqueWildcard
like the statements abit below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably can. I was originally trying to avoid adding an extra includes flag, which, for unions, was possible by exploiting the sort order of the result set; however intersections are unsorted, so I had to add a flag to handle it there.
If I read the build correctly then DT has no issues? Are the diff's for fp-ts in the user tests a result of this change? There are some new errors related to overload resolution which seems to be a touch point for this change. The previous output was a GC dump so I don't have a good sense about whether this change is going to cause any troubles. From the POV of fixing #31251 I think this looks good. I don't understand the full implications of the change to overload resolution but the diff in |
Unfortunately, we never finished reviewing this PR. It is pretty old now, so I'm going to close it to reduce the number of open PRs. |
This PR is essentially #41067 + #31277, with a change added on top so it also fixes #43867.
Fixes #43867 (we always now reliably issue the correct error (which is a new thing), rather than just for variance comparisons, as in
master
)Fixes #23352 (we now use a wildcard marker for type erasure that is assignable to
never
, which allows overload resolution to process the overloads as we'd like)Fixes #31251 (we now force a structural comparison when comparing type parameters which flow into conditional
extends
clauses (which require identical types))Fixes #44945