Represents a hashmap type constructed from a collection type D.
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.
K
string
number
The object type which must extend ObjectType.
ObjectType
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 } Copy
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;}; Copy
export type HashMapType< D extends ObjectType, K extends keyof D = StringNumberKeys<D>> = { [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
KofD(which must be astringornumber), and values are of typeD.