TypeScript Types
Object types — structural member contracts
An object type describes required members and their types. It usually permits values with extra members if they satisfy the required structure; fresh object literals receive additional excess-property checking. Optional and readonly modifiers change the static contract. A type declaration does not create an object or ensure its shape at runtime. Example output: "Ada". The example was designed for strict checking with an ES2022 target; type annotations do not add runtime validation.
Formal Syntax & Structure
typescript syntaxtypescript
type Person = { name: string; age: number };Working Example
Example Snippettypescript
type Person = { name: string };const employee = { name: "Ada", department: "QA" };const person: Person = employee;console.log(person.name);