Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wonderful-panda opened this issue Dec 12, 2016 · 0 comments · Fixed by #12843
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@wonderful-panda
Copy link
Contributor

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.

@ahejlsberg ahejlsberg added Bug A bug in TypeScript Fixed A PR has been merged for this issue labels Dec 12, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants