Object type
Describes the shape of an object by its properties and methods.
Syntax
{ prop: Type; method(): Type } Examples
type User = {
id: number;
name: string;
active?: boolean;
readonly createdAt: Date;
};
function move(p: { x: number; y: number }) {
return p.x + p.y;
}
Notes
Object type literals list properties with optional (`?`) and `readonly`
modifiers, methods, call/construct signatures, and index signatures.
TypeScript uses structural typing, so any value with a compatible shape is
assignable. Use `type` or `interface` to name reusable shapes.