You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Some useful Typescript utility types// Utility types constructs a type subset from a given type// T = Input type// Refrence type (T)interfaceIUser{firstname: stringlastname: stringage: numberincome: undefined}// Partial<T> - Constructs a type with all properties of T set to optionalconstpartialT: Partial<IUser>={}// all properties of IUser are now optional [?]// Pick<T, Keys> - Constructs a type by picking a set of properties [Keys] from TconstpickT: Pick<IUser,"firstname"|"age">={}// PickT now has only firstname and age fields// Readonly<T> - Constructs a type from T with all properties set to readonlyconstreadonlyT: Readonly<IUser>={}// all properties of IUser are now readonly// NonNullable<T> - Constructs a type by excluding all null and undefined from TconstnonNullableT: NonNullable<IUser>={}// income field is excluded// Omit<T, Keys> - Constructs a type by picking all properties of T except [Keys]constomitT: Omit<IUser,"age"|"income">={}// age and income are exluded from IUser