Creates a new type by selecting specific properties from an existing type.
type PickedType = Pick<OriginalType, 'key1' | 'key2'>;
interface User {
id: number;
name: string;
email: string;
password: string;
createdAt: Date;
role: string;
}
*// Profile display only needs these fields*
type UserProfile = Pick<User, 'id' | 'name' | 'email'>;
*// Login credentials*
type LoginCredentials = Pick<User, 'email' | 'password'>;
const profile: UserProfile = {
id: 1,
name: "John",
email: "john@example.com"
*// password not needed or allowed*
};
Omit instead