Typing objects in TypeScript
BRANK

In this blog post, we will explore how objects and properties are typed statically in TypeScript.Table of contents:Roles played by objects  Plain object types  Object vs. object  Object with uppercase “O”: instances of class Object  object with lowercase “o”: non-primitive values  Object vs. object: primitive values  Object vs. object: incompatible property types  Object type literals and interfaces  Nominal type systems vs. structural type systems  Members of interfaces and object type literals  Index signatures: objects as dicts  Interfaces describe instances of Object  Excess property checks  Type inference  Other features of interfaces  Optional properties  Read-only properties  JavaScript’s prototype chains and TypeScript’s types  Sources of this blog post  Roles played by objects  In JavaScript, objects can play two roles (always at least one of them, sometimes mixtures):Records: A fixed amount of properties that are known at development time. Each property can have a diff…

2ality.com
Related Topics: AltJS TypeScript
1 comments