TypeScript Syntax and Type Operators
readonly — property modifier
A readonly property cannot be assigned through the declared readonly view after initialization. It does not recursively make nested objects immutable, and it does not freeze the runtime object. TypeScript permits some structural assignments between mutable and readonly property shapes; another reference may therefore mutate the same object. Example output: "2". Tested in the strict TypeScript 5.8.3 / ES2022 baseline; the example is not a runtime type validator.
Formal Syntax & Structure
typescript syntaxtypescript
interface Settings { readonly label: string; }Working Example
Example Snippettypescript
const source = { count: 1 };const view: { readonly count: number } = source;source.count = 2;console.log(view.count);