Represents an object type with string or number keys and values of type T.
T
This utility type is a shorthand for objects where keys can be either string or number, and all values have the same type T.
string
number
The type of the object’s values. Defaults to unknown.
unknown
type UserMap = ObjectType<User>;// Equivalent to: Record<string | number, User>const users: UserMap = { 1: { name: "Alice" }, "2": { name: "Bob" }}; Copy
type UserMap = ObjectType<User>;// Equivalent to: Record<string | number, User>const users: UserMap = { 1: { name: "Alice" }, "2": { name: "Bob" }};
export type ObjectType<T = unknown> = Record<string | number, T> Copy
export type ObjectType<T = unknown> = Record<string | number, T>
Represents an object type with string or number keys and values of type
T.This utility type is a shorthand for objects where keys can be either
stringornumber, and all values have the same typeT.