Skip to content

Latest commit

 

History

History

omit-properties

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

OmitProperties<Type, Value> constructs a type by picking all properties from type Type and removing those properties which values equal to Value

interface UserInformation {
  birthday: Date;
  email: string;
  id: string;
  name: string;
  happyBirthday: () => void;
  hello: () => void;
}

type UserFields = OmitProperties<UserInformation, Function>;
//   ^? { birthday: Date; email: string; id: string; name: string; }

Value can also be a union type

type UserActions = OmitProperties<UserInformation, Date | Primitive>;
//   ^? { happyBirthday: () => void; hello: () => void; }

TS Playground – https://tsplay.dev/m3xVqW