Skip to content

Error in Diff / Omit types #21148

@ghost

Description

TypeScript Version: 2.7.0-dev.20180111

Code

type Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;

Expected behavior:

No error.

Actual behavior:

src/a.ts(3,43): error TS2344: Type '({ [P in T]: P; } & { [P in U]: never; } & { [x: string]: never; })[keyof T]' does not satisfy the constraint 'keyof T'.
  Type '({ [P in T]: P; } & { [P in U]: never; })[keyof T]' is not assignable to type 'keyof T'.

These types were taken from #12215 (comment) so are present in a few DefinitelyTyped packages.
There was no error in typescript@2.7.0-dev.20180110. Error discovered in recompose (among others) on DefinitelyTyped.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions