Skip to content
AgileLogics
4 min read

Objects and Type Shapes

Prerequisites: Basic types

An inline object type describes exactly which properties an object must have, and their types.

let user: { name: string; age: number };

user = { name: "Ada", age: 25 };
user = { name: "Ada" }; // Property 'age' is missing

Writing the shape inline like this works for a one-off variable, but for anything reused, an interface (next lesson) is the standard, named way to describe it.