Classes in TypeScript
Parameter Properties (Constructor Shorthand)
Declare and initialize class members directly inside constructor parameter signatures.
Last Updated: July 29, 2026
•
10 min read
Parameter properties allow declaring and initializing class fields directly within the constructor argument list.
1. Introduction & Architecture
2. Deep Dive & Core Concepts
Prefixing a constructor argument with public, private, protected, or readonly creates a field automatically.
3. Basic Code Example
4. Advanced Production Patterns
5. Interactive Code Playground
class Hero {
constructor(public alias: string, private secret: string) {}
}
const h = new Hero("Batman", "Bruce Wayne");
console.log(h.alias);
6. Common Pitfalls & Edge Cases
Note: Parameter properties cannot be combined with explicit field declarations of the same name.
7. Interview Q&A & Quizzes
Q: What are parameter properties in TypeScript?
A: A shorthand syntax that automatically creates and assigns class fields from constructor arguments.
8. Summary Comparison Table
| Shorthand Parameter | Equivalent Standard Code |
|---|
constructor(public id: string) | id: string; constructor(id: string) { this.id = id; } |