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 3.7typescriptlang.org
- Shikishiki.style
- Reading 2: Basic TypeScriptweb.mit.edu
- TypeScript: Documentation - Genericstypescriptlang.org
- Typing Component Props | React TypeScript Cheatsheetreact-typescript-cheatsheet.netlify.app
- Basic TypeScriptweb.mit.edu
- Typescript utility types that you must know - DEV Communitydev.to
- TypeScript: Documentation - More on Functionstypescriptlang.org
- TypeScript: Documentation - Classestypescriptlang.org
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- TypeScript: Documentation - TypeScript 3.8typescriptlang.org