Creates a readonly record type with keys of type K and values of type T. All properties are readonly and cannot be modified after creation.
K
T
The type of keys, must extend PropertyKey (string | number | symbol).
PropertyKey
The type of values.
A readonly record type.
type Config = ReadonlyRecord<string, string | number>;const settings: Config = { host: 'localhost', port: 3000 };// settings.host = 'new-host'; // Error: Cannot assign to 'host' because it is a read-only property Copy
type Config = ReadonlyRecord<string, string | number>;const settings: Config = { host: 'localhost', port: 3000 };// settings.host = 'new-host'; // Error: Cannot assign to 'host' because it is a read-only property
Creates a readonly record type with keys of type
Kand values of typeT. All properties are readonly and cannot be modified after creation.