How to Omit multiple properties in a succint way using Omit

You just need to use a union as the second type parameter to remove all constituents in the union from the first type parameter:

export type A = Readonly<{
  x: number;
  y: number;
  j: string;
  k: string;
}>;

export type B = Omit<A, 'j' | 'k'>
// Same as
// type B = {
//     readonly x: number;
//     readonly y: number;
// }

play

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)