-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Description
This seems to be the source: #31838
Example:
Try an intersection of 2 types where the same property has inconsistent overlapping types:
type Bar = {
Prop: string
};
type Works = Bar & {Prop: number}; // Bar & {Prop: number}
type ThisIsNever = Bar & {Prop: null}; // never
It makes sense to me that individual types can be reduced to never, but why can intersecting types with nested overlapping property types get reduced to never?
This might be expected, but it does feel like a bug to me. My initial use case was joining a few different types together to get a union of all their keys. But since some props had a null | undefined type, it was reduced to never. Causing my use of those keys to fail unexpectedly. I would expect ThisIsNever to have a Prop: never property instead, or maybe a union of string | null. Or at-least surface an error saying the union is not possible because of Prop being incompatible.
Tested on: 4.6.4, 4.7.0-beta
This worked as expected in: v3.8.3. And starts not being expected in v3.9.7