Home > types-kit > ConditionalOmit
Omit by Condition (value).
Signature:
export type ConditionalOmit<
T,
Condition,
Exact extends boolean = false,
> = StrictOmit<T, ConditionalKeys<T, Condition, Exact>>References: StrictOmit, ConditionalKeys
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>