stack

Home > @infiniteobjects/type-utils > ConditionalKeys

ConditionalKeys type

Extract the keys from a type where the value type of the key extends the given Condition.

Signature:

export type ConditionalKeys<Base, Condition> = NonNullable<{
    [Key in keyof Base]: Base[Key] extends Condition ? Key : never;
}[keyof Base]>;

Remarks

To support partial types, make sure your Condition is a union of undefined (for example, string | undefined)