01 / 05
Destructuring, with types
Remember pulling names out of an object? const { name, age } = person; from the JavaScript course.
In TypeScript, the variables you pull out get types. The syntax is a little unusual — you write the type after the whole pattern, not after each name.
const person = { name: "Yui", age: 20 };const { name, age }: { name: string; age: number } = person;console.log(name, age);Result
Yui 20