Type alias ReadOnlyArray<Item>

ReadOnlyArray<Item>: ReadOnly<Item[]>

Read-only array.

Remarks

There's already a native ReadonlyArray type, but this type has a default type parameter to make it easier to use when the type of an array is unknown, plus it recursively makes all the items in the array read-only.

Example

const array: ReadOnlyArray<{ "🟢": number }> = [{ "🟢": 1}, { "🟢": 2 }];
array[0]["🟢"] = 3; // Error

See

ReadOnly

Type Parameters

  • Item = unknown

    Type of the items in the array.