Interfaces name the shape expected from an object. They are compile-time descriptions, not JavaScript classes or values created at runtime.
Interfaces
TypeScript
interface User { id: number; name: string; } const user: User = { id: 1, name: "Ada" };
TypeScript uses structural typing: an object is suitable when it has the required shape, even if it was created elsewhere.
Optional properties
Add ? when a property may be absent. With strict checking, test it before assuming it is present.
TypeScript
interface User { name: string; email?: string; }
Did you know my courses are all printer-friendly? This means you can easily export them to PDF or print them for later use.
