TypeScript Syntax and Type Operators
interface — object contract declaration
An interface names an object shape whose members are checked structurally. It can describe callable or constructible objects as well as ordinary records. Separate compatible interface declarations in the same scope can merge; incompatible declarations cause errors. It is erased during emission and does not construct an object. Example output: "true". Tested in the strict TypeScript 5.8.3 / ES2022 baseline; the example is not a runtime type validator.
Formal Syntax & Structure
typescript syntaxtypescript
interface Task { id: number; done: boolean; }Working Example
Example Snippettypescript
interface Task { id: number; }interface Task { done: boolean; }const task: Task = { id: 4, done: true };console.log(task.done);