Lesson 43 of 55
15 mins readPython Partial, Required, and Readonly
In Plain English
TypeScript includes built-in utility types that facilitate common type transformations. Learn when and how to apply Partial<T>, Required<T>, and Readonly<T>.
Core Rules to Remember

Partial<T>: Marks all properties of T as optional, ideal for PATCH updates.

Readonly<T>: Marks all properties of T as immutable, preventing reassignment.
Live Interactive Example
Hit Run Code to see it liveApplying Partial, Required, and Readonly
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Output Console
Click "Run Code" to view the rendered output.
How it works: Partial<T> allows partial objects for updates, while Readonly<T> guarantees immutability.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Create an Immutable Settings Object
Define interface AppSettings { theme: string; soundEnabled: boolean }.
Create type ReadonlySettings = Readonly<AppSettings>.
Create const settings: ReadonlySettings = { theme: "dark", soundEnabled: true } and print `${settings.theme} ${settings.soundEnabled}`.
1
2
3
4
5
6
7
8
9
10
11
12
13
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.