author avatar

ashwanikumarjha

Sun May 07 2023

TypeScript Pick utility allows us to create a new type by picking a subset of properties from an existing type. Instead of duplicating field declarations we can use Pick utility to extract new types.

type AdminUser = {
  id: number;
  name: string;
  email: string;
  phone: string;
  password: string;
  age: number;
  isAdmin:  boolean;
  ...
}
type BasicUser = Pick<AdminUser, 'id' | 'name' | 'email'>;