Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 868 Bytes

File metadata and controls

35 lines (25 loc) · 868 Bytes

Home > types-kit > ConditionalOmit

ConditionalOmit type

Omit by Condition (value).

Signature:

export type ConditionalOmit<
  T,
  Condition,
  Exact extends boolean = false,
> = StrictOmit<T, ConditionalKeys<T, Condition, Exact>>

References: StrictOmit, ConditionalKeys

Example

 interface Props {
      a?: number
      b: string
      c: boolean
    }

 // Expect: { b: string }
 type NewProps = ConditionalPick<Props, number | boolean>
  // Set exact true, expect: { a?: number, b: string }
 type NewProps2 = ConditionalPick<Props, number | boolean, true>