my-swiss-knife: - v1.9.9
    Preparing search index...

    Type Alias HashMapType<D, K>

    HashMapType: { [key in D[K] & (string | number)]: D }

    Represents a hashmap type constructed from a collection type D.

    Keys of the hashmap are derived from the property K of D (which must be a string or number), and values are of type D.

    Type Parameters

    • D extends ObjectType

      The object type which must extend ObjectType.

    • K extends keyof D = StringNumberKeys<D>

      The key of D whose values will be used as keys in the hashmap. Defaults to the keys of D whose values are string or number.

    type User = { id: number; name: string };
    type UserMap = HashMapType<User, 'id'>;
    // Equivalent to { [key: number]: User }
    export type HashMapType<
    D extends ObjectType,
    K extends keyof D = StringNumberKeys<D>
    > = {
    [key in D[K] & (string | number)]: D;
    };