What is a class in TypeScript?

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.