Home > types-kit > ConditionalPick
Pick by Condition (value).
Signature:
export type ConditionalPick<T, Condition, Exact extends boolean = false> = Pick<
T,
ConditionalKeys<T, Condition, Exact>
>References: ConditionalKeys
interface Props {
a?: number
b: string
c: boolean
}
// Expect: { a?: number, c: boolean }
type NewProps = ConditionalPick<Props, number | boolean>
// Set exact true, expect: { c: boolean }
type NewProps2 = ConditionalPick<Props, number | boolean, true>