-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Search Terms
pick, nested, deep
Suggestion
Pick
can only be used to access properties at the top level of an object, it should support paths to get at more deeply nested values.
Use Cases
Typing form inputs from GraphQL fragments
Examples
type Company = {
id: number;
name: string;
address: {
id: number;
street: string;
city: string;
state: string;
};
}
You could then construct a new type as follows:
type FlatCompany = Pick<Company, "id" | "name" | { "addressId": ["address", "id"] }>
Which would yield:
type FlatCompany = {
id: number;
name: string;
addressId: number;
}
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
jeffreysilver, johnyrico, admarko and rpedroni-sf
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug