Lesson 33 of 55
15 mins readPython Parameter Properties Shorthand
In Plain English
TypeScript allows you to turn constructor parameters into class properties by prefixing them with an access modifier or readonly keyword.
Core Rules to Remember

Boilerplate Reduction: Combines declaration, parameter receipt, and assignment in one keyword.

Cleaner Constructors: Keeps constructor body focused purely on initialization logic.
Live Interactive Example
Hit Run Code to see it liveConcise Class Definitions
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Output Console
Click "Run Code" to view the rendered output.
How it works: Prefixing constructor parameters with public or private automatically declares and assigns instance fields.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Refactor to Parameter Properties
Create class Vehicle with constructor(public readonly brand: string, public speed: number).
Add method accelerate(amount: number): number that increases speed by amount and returns speed.
Instantiate with "ZenMotors", 60, call accelerate(20), and print brand and speed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.