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
related reading
- TypeScript: Documentation - The Basicstypescriptlang.org
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- Shikishiki.style
- TypeScript: Documentation - TypeScript 3.7typescriptlang.org
- TypeScript: Documentation - Classestypescriptlang.org
- TypeScript: Documentation - More on Functionstypescriptlang.org
- TypeScript: Documentation - Genericstypescriptlang.org
- Typescript utility types that you must know - DEV Communitydev.to
- Typing Component Props | React TypeScript Cheatsheetreact-typescript-cheatsheet.netlify.app
- Reading 8: Defining ADTs with Interfaces, Generics, Enums, and Functionsweb.mit.edu
- TypeScript Structured Concurrencythecandidstartup.org
- Reading 12: Defining ADTs with Interfaces, Generics, Enums, and Functionsweb.mit.edu