Readonly, Exclude, Extract, NonNullable
Apply more utility types for immutability and filtering.
Readonly, Exclude, Extract, NonNullable is a free TypeScript Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Welcome
Readonly<T>
interface Config { host: string; port: number; }
const cfg: Readonly<Config> = { host: 'localhost', port: 3000 };
// cfg.host = 'remote'; // Error!Exclude<T, U>
type Status = 'pending' | 'active' | 'banned' | 'deleted';
type ActiveStatus = Exclude<Status, 'banned' | 'deleted'>;
// 'pending' | 'active'Extract<T, U>
type StringOrNumber = string | number | boolean;
type JustStrNum = Extract<StringOrNumber, string | number>;
// string | numberNonNullable<T>
type MaybeString = string | null | undefined;
type DefinitelyString = NonNullable<MaybeString>; // stringReturnType<T>
function fetchUser() { return { id: 1, name: 'Alice' }; }
type User = ReturnType<typeof fetchUser>; // { id: number; name: string }Parameters<T>
function add(a: number, b: number): number { return a + b; }
type AddParams = Parameters<typeof add>; // [number, number]InstanceType<T>
class HttpClient { get(url: string) { return fetch(url); } }
type Client = InstanceType<typeof HttpClient>; // HttpClientAwaited<T>
type A = Awaited<Promise<string>>; // string
type B = Awaited<Promise<Promise<number>>>; // numberUsing Multiple Utilities Together
type SafeInput<T> = Readonly<Partial<NonNullable<T>>>;Utility Types Are Just Type Aliases
Quick Check
Recap
Frequently asked questions
Is the “Readonly, Exclude, Extract, NonNullable” lesson free?
Yes — the full text of “Readonly, Exclude, Extract, NonNullable” is free to read here on the web, and the TypeScript Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Readonly, Exclude, Extract, NonNullable”?
Apply more utility types for immutability and filtering. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start TypeScript Academy?
No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Readonly, Exclude, Extract, NonNullable” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this TypeScript Academy lesson?
Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
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