Class with TypeScript

Classes in TypeScript work similarly to classes in ES6 but with type annotations.

Snippet:

class Person { name: string; age: number; constructor(name: string, age: number) { this.name = name; this.age = age; } }

Example:

class Car { make: string; model: string; constructor(make: string, model: string) { this.make = make; this.model = model; } }