Record type allows you to create object types in a shorter way. Types for objects are normally defined in the below format:
type UserDetailType = {
name: string;
age: string;
};
type Users = {
[name: string]: UserDetailType
};
However, with the Record
utility you can construct the same type as follows
type UserDetailType = {
name: string;
age: string;
};
type Users = Record<string, UserDetailType>;