Pick<T, K>
Constructs a type by selecting the set of properties K from T.
Syntax
Pick<Type, Keys> Returns
object type — A type containing only the properties of T whose keys are in the union K.
Examples
interface User {
id: number;
name: string;
email: string;
}
type Preview = Pick<User, 'id' | 'name'>;
const p: Preview = { id: 1, name: 'Ada' };
type Coords = Pick<DOMRect, 'x' | 'y'>;
Notes
K must be a subset of `keyof T`; unknown keys are a compile error. Property
modifiers such as `readonly` and `?` are preserved. Use `Omit` for the inverse
selection.