TypeScript tutorialLesson 9Free preview
TS Object Types
This lesson is part of TypeScript · All levels
Summary
Object type describes the shape of an object as a list of properties and their types. You can write it directly to the variable annotation, including marking the optional property. The compiler will reject objects whose properties do not conform to the declaration.
Key points
- Object type is written as {name: type;...}
- Optional property using the question mark
- Readonly preventing changes in property values
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.