What is a class in TypeScript?

Why Interviewers Ask This

This is a classic screening question for TypeScript roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

TypeScript classes extend JavaScript ES6 classes with additional features for type safety. A basic TypeScript class: class Animal { name: string; constructor(name: string) { this.name = name; } speak(): void { console.log(this.name + " makes a sound."); } }. TypeScript adds: Access modifierspublic (default, accessible anywhere), private (only within the class), protected (within class and subclasses). readonly properties. Parameter properties — shorthand for declaring and initializing in the constructor: constructor(private name: string, public age: number) {}. Abstract classes — cannot be instantiated, serve as base classes. Implements — a class can implement multiple interfaces. Static members — belong to the class itself, not instances. TypeScript classes support full inheritance with extends. TypeScript also supports private class fields using the # syntax (JavaScript standard) which provide true runtime privacy, unlike TypeScript's private which is only a compile-time check.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex TypeScript answers easy to follow.