TS4104
error TS4104: The type ‘
readonly [1, 2, 3]
‘ is ‘readonly’ and cannot be assigned to the mutable type ‘[1, 2, 3]
‘.
Broken Code ❌
1 |
|
Fixed Code ✔️
Using a const assertion makes your array immutable, so you have to use the readonly
modifier for its type:
1 |
|
Alternative:
1 |
|
Alternative #2:
1 |
|