devtypes
    Preparing search index...

    Type Alias KeysByValue<T, V>

    KeysByValue: { [K in keyof T]-?: T[K] extends V ? K : never }[keyof T]

    Extract keys of T whose values match V

    Type Parameters

    • T
    • V
    type Obj = { a: number; b: string; c: number; d: boolean };
    type NumKeys = KeysByValue<Obj, number>; // "a" | "c"