Declare Read-Only Array Types in TypeScript

Share this video with your friends

Send Tweet

TypeScript lets us define array types as read-only so that we get a type error if we attempt to add, remove, or replace any elements of the array. We can use the readonly keyword to make an array type read-only. Alternatively, we can use the ReadonlyArray<T> type instead of Array<T> or T[].

Additional Reading