Thuta Learning
TypeScript
IntermediateProgrammingintermediate

Objects

You can define an object's shape using a type annotation — specifying up front which properties it should have and what type each one is.

typescript
const person: { name: string; age: number } = {
  name: "John Doe",
  age: 30
};

console.log(`${person.name} is ${person.age} years old.`);
You should see
John Doe is 30 years old.