Closed
Description
With microsoft/TypeScript#36696 we treat intersections of object types with discriminant properties of disjoint types as eqivalent to never
(the empty type), since objects of such types are not possible to construct. This change causes the DefinitelyTyped test suite for ramda
to fail, which in turn is caused by an issue in ts-toolbelt
. Specifically, module List/Merge
has the following type:
type MergeFlatTuple<L extends List, L1 extends List> = ListOf<ObjectOf<{
[K in keyof (L & L1)]: [At<L, K>] extends [never] ? At<L1, K> : At<L, K>;
}>>;
With the PR, when L & L1
is an empty intersection we now substitute never
, which causes this type to never terminate. The type should be changed to:
type MergeFlatTuple<L extends List, L1 extends List> = ListOf<ObjectOf<{
[K in keyof L | keyof L1]: [At<L, K>] extends [never] ? At<L1, K> : At<L, K>;
}>>;
This produces the same key types as before (i.e. the change is backwards compatible), but avoids the empty intersection test.
Metadata
Metadata
Assignees
Labels
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
millsp commentedon Feb 26, 2020
Thanks for the PR, glad it got implemented. I will propagate the change through the library. And it probably explains the reason why my tests were failing #95 .
Thanks
fix: fixes type intersections #95 #96
millsp commentedon Feb 26, 2020
fixed