Skip to content

Mapped Type with generics shows different behaviour to from non-generics type #12842

Closed
@wonderful-panda

Description

@wonderful-panda

TypeScript Version: nightly (2.2.0-dev.20161211)

Code

type Foo = { foo: string, bar?: string };
type X<T> = { [K in keyof T]: any };
type FooX = { [K in keyof Foo]: any };

const a: X<Foo> = { foo: "foo" };  // passed
const b: FooX = { foo: "foo" };  //  failed: property 'bar' is missing

Expected behavior:
Both passed or both failed (maybe both passed)

Actual behavior:
Comment in code.

Metadata

Metadata

Assignees

No one assigned

    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