TypeScript's type system is…
Options
- Nominal: types match only by their declared name
- Structural: types are compatible if shapes match (Correct option)
- Dynamic: types are checked at runtime instead
- Identical to the type system that Java uses
Answer
Structural: types are compatible if their shapes match
Why
TypeScript compares the SHAPE of types, not their names. If an interface requires { id: number; name: string }, any object with those properties fits, even if it was never declared as that interface.
Also, types disappear when TypeScript compiles to JavaScript, so data from outside still needs runtime validation.
Remember
TypeScript checks shape, not name, and only at compile time.