TYPESCRIPTChapter 1 · TS Basics
Describing objects with interfaces
An interface names the shape of an object: which properties it has and their types. Annotate a value with the interface and the compiler enforces the shape.
Worked example
How it reads
- interface Cloud { ... } names a reusable object shape
- isFluffy? marks the altitude-related field as optional

Cloud tip: Use optional properties with a question mark to allow fields to be omitted safely.


