Readonly, Exclude, Extract, NonNullable
Apply more utility types for immutability and filtering.
Welcome
TypeScript's standard library includes several utility types beyond Partial, Required, Pick, and Omit. This lesson covers Readonly, Exclude, Extract, and NonNullable.
Readonly<T>
Makes all properties of T readonly. Prevents any property reassignment after creation.
interface Config { host: string; port: number; }
const cfg: Readonly<Config> = { host: 'localhost', port: 3000 };
// cfg.host = 'remote'; // Error!All lessons in this course
- Partial and Required: Toggling Optionality
- Pick and Omit: Selecting Properties
- Record: Mapping Keys to Value Types
- Readonly, Exclude, Extract, NonNullable