Skip to content

Can't write a 'pick' function that accurately infers type arguments #12455

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
DanielRosenwasser opened this issue Nov 23, 2016 · 0 comments
Closed
Assignees
Labels
Bug A bug in TypeScript

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Nov 23, 2016

declare function pick<T, K extends keyof T>(obj: T, propNames: K[]): Pick<T, K>;

let x = pick({ a: 10, b: 20, c: 30 }, ["a", "c"]);
let b = x.b;

Expected: Error on accessing x.b.
Actual: No error.

@ahejlsberg ahejlsberg added the Bug A bug in TypeScript label Nov 24, 2016
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Nov 24, 2016
@DanielRosenwasser DanielRosenwasser removed the Fixed A PR has been merged for this issue label Nov 24, 2016
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 2.1.3 milestone Nov 24, 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
Projects
None yet
Development

No branches or pull requests

2 participants