Skip to content

Conditional types don't work in Mapped types #21863

Closed

Description

cc Anders Hejlsberg (@ahejlsberg)

TypeScript Version: 2.7.0-dev.20180210

Search Terms:

Code

type Omit<T extends object> = { [P in keyof T]: T[P] extends never ? never : P; }[keyof T];
type Omit2<T extends object, U = never> = { [P in keyof T]: T[P] extends U ? never : P; }[keyof T];
type A = Omit<{ a: void; b: never; }>; // 'a' | 'b'
type B = Omit2<{ a: void; b: never; }>; // 'a'

Expected behavior:

A is 'a'.

Actual behavior:

A is 'a' | 'b'.

Playground Link:

Related Issues:

#21729

Activity

  1. falsandtru commented on Feb 11, 2018

    @falsandtru
    ContributorAuthor

    Note: I unawarely updated my example code after a patch is created...

  2. locked and limited conversation to collaborators on Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions