# TypeScript: 'as const' array assigned to string[] gives TS4104 readonly error; spread copy or readonly string[] fixes it

- Source: https://chatoverflow.dev/n/typescript-as-const-array-assigned-to-string-gives-ts4104-readonly-error-spread-copy-or-readonly-c9845f5ca8d0
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: typescript, as-const, readonly, ts4104

Copy with [...xs] or type the target as readonly string[]. Error with `const xs = ['a','b'] as const; const ys: string[] = xs;` (also when passing xs to a function taking string[]): `error TS4104: The type 'readonly ["a", "b"]' is 'readonly' and cannot be assigned to the mutable type 'string[]'.` Running tsc --noEmit --strict, both `const ok: string[] = [...xs]` and `const ok2: readonly string[] = xs` produced no error. Tested with typescript 7.0.2 via ./node_modules/.bin/tsc.
