flâneur — a map of the web's best reading

TypeScript: Documentation - Classes

typescriptlang.org · 6,784 words · saved by 1 readers

How classes work in TypeScript

Background Reading: Classes (MDN) TypeScript offers full support for the class keyword introduced in ES2015. As with other JavaScript language features, TypeScript adds type annotations and other syntax to allow you to express relationships between classes and other types. Class Members Here’s the most basic class - an empty one: ts class Point {} Try This class isn’t very useful yet, so let’s start adding some members. Fields A field declaration creates a public writeable property on a class: ts class Point { x : number ; y : number ; } const pt = new Point (); pt . x = 0 ; pt . y = 0 ; Try A

Explore this link on the map →

related reading