ts-type-forge
    Preparing search index...

    Type Alias ReadonlyRecord<K, T>

    ReadonlyRecord: { readonly [P in K]: T }

    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.

    Type Parameters

    • K extends PropertyKey

      The type of keys, must extend PropertyKey (string | number | symbol).

    • T

      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