On this page
  1. Readonly
  2. Syntax & Overview
  3. Notes & Pitfalls
  4. Example

Readonly

Prev: `Required` | Up: object_transforms | Next: `Record`
Rel: object_transforms, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #object_transforms #tier/core


Syntax & Overview

Readonly<T>

Marks every top-level property of T as readonly.

Notes & Pitfalls

Example

interface State { count: number; label: string }
const frozen: Readonly<State> = { count: 0, label: "init" };
// frozen.count = 1; // compile-time error

Linked from

Related notes