devtypes - v1.1.0
    Preparing search index...

    Type Alias KeysByValue<T, V>

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

    Extract keys of an object whose values match a type.

    Type Parameters

    • T

      The object type to filter

    • V

      The value type to match

    Filters object keys based on their value type. Useful for mapping or picking properties programmatically.

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