GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||
GeezerVison is showing github.com — Empty intersection reduction by ahejlsberg · Pull Request #31838 · microsoft/TypeScript Conversation
|
|
TypeScript Bot (@typescript-bot) test this |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 015f4c5. You can monitor the build here. It should now contribute to this PR's status checks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 015f4c5. You can monitor the build here. It should now contribute to this PR's status checks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
RWC test run is clean. DT test run has one minor difference in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Does this still support branding via object literals? type Tag<T> = T & { readonly brand: unique symbol }; type TaggedNumber = Tag<number>; // not never |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Jack Williams (@jack-williams) It does, except you can't brand |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Jack Williams (@jack-williams) The only thing that changes with this PR is when we reduce away empty intersections. We now do it upon construction but we used to do it only when an intersection was put in a union type. The actual patterns we reduce away (or don't reduce away) remain the same. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Ah, that makes it clearer. Thank you! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (type.flags & TypeFlags.Unit && includes & TypeFlags.Unit) { | ||
| // We have seen two distinct unit types which means we should reduce to an | ||
| // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. | ||
| includes |= TypeFlags.NonPrimitive; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Counterexample:
enum A { Zero = 0, One = 1 } type Zeroish<T> = T & 0; type ShouldNotBeNever = Zeroish<A.Zero> | never;
we handle this incorrectly in master already - I'm just not a fan of propagating the logical error.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
So is the reason for that that the code highlighted considers A.Zero and 0 to be distinct? I'm just trying to ascertain where in that example above the never creeps in.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Wesley Wigham (@weswigham) I think it is debatable whether we want to consider literals and literal enum members with the same underlying value to be intersectable. But either way, it is an issue that should be covered in a separate PR. Here we're just concerned with changing when we reduce, not how.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 015f4c5. You can monitor the build here. It should now contribute to this PR's status checks. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
RWC and DT test runs are both clean now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I expect we'll get some reports about the using-an-enum-to-tag break upon release - we should remember to include this in the breaking change log.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi I wanted to check to see if this has already been resolved as I am still facing this issue. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Utilizing [TypeScript intersection](microsoft/TypeScript#31838) to simplify config types. Config keys and payload can now always be `undefined`.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Type 'any' is not assignable to type 'never' with boolean in interface in TS 3.5
There was an error while loading. Please reload this page.