Lesson 07 of 55
15 mins readPython Object Types and Shapes
In Plain English
Define and enforce structured object shapes in TypeScript using inline property definitions, optional modifiers, and readonly fields.
Core Rules to Remember

Explicit Shapes: Enforces exact property presence and type matches on object instances.

Readonly Modifier: Prevents property re-assignment after object initialization.
Live Interactive Example
Hit Run Code to see it liveDeclaring Structured Object Types
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Output Console
Click "Run Code" to view the rendered output.
How it works: TypeScript validates mandatory fields, forbids mutation of readonly fields, and allows optional fields.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Enforce Immutable System Metadata
Declare a config object variable with an explicit type.
It must have a readonly string uuid, string environment, and optional number timeoutMs.
Initialize it with uuid "srv-882", environment "production", and print uuid and environment.
1
2
3
4
5
6
7
8
9
10
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.