How do you declare a class in TypeScript?

Instruction: Provide an example of a class declaration, including properties and methods.

Context: This question evaluates the candidate's understanding of object-oriented programming concepts within TypeScript, including class syntax.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

A class combines instance state with methods and a constructor that initializes that state. TypeScript checks declared property and method contracts; the emitted JavaScript class provides the runtime behavior.

```typescript class User { private readonly id: number; public firstName: string; public lastName: string;...

Related Questions