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

TypeScript: Documentation - Object Types

typescriptlang.org · 5,856 words · saved by 1 readers

How TypeScript describes the shapes of JavaScript objects.

In JavaScript, the fundamental way that we group and pass around data is through objects. In TypeScript, we represent those through object types . As we’ve seen, they can be anonymous: ts function greet ( person : { name : string ; age : number }) { return "Hello " + person . name ; } Try or they can be named by using either an interface: ts interface Person { name : string ; age : number ; } function greet ( person : Person ) { return "Hello " + person . name ; } Try or a type alias: ts type Person = { name : string ; age : number ; }; function greet ( person : Person ) { return "Hello " + pe

Explore this link on the map →

related reading