TypeScript Tutorial #5: Objects and Interfaces
In the previous tutorial, we learned how to type functions. Now let’s learn how to describe the shape of objects — one of the most important skills in TypeScript. By the end of this tutorial, you will know how to define object types, use interfaces, extend them, and choose between interfaces and type aliases. Object Types You can describe an object’s shape by listing its properties and types: let user: { name: string; age: number } = { name: "Alex", age: 25, }; TypeScript checks that the object matches the shape: ...