Skip to content

Change needed to prepare for TS #36696 #96

Closed
@ahejlsberg

Description

@ahejlsberg

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.

Activity

self-assigned this
on Feb 26, 2020
millsp

millsp commented on Feb 26, 2020

@millsp
Owner

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

added a commit that references this issue on Feb 26, 2020
millsp

millsp commented on Feb 26, 2020

@millsp
Owner

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @ahejlsberg@millsp

      Issue actions

        Change needed to prepare for TS #36696 · Issue #96 · millsp/ts-toolbelt