Overview - How structural typing differs from nominal typing
What is it?
Structural typing and nominal typing are two ways programming languages check if types match. Structural typing checks if the shape or structure of data fits what is expected, like matching puzzle pieces. Nominal typing checks if types have the same name or label, like matching ID cards. TypeScript uses structural typing, meaning it cares about what properties an object has, not what it is called.
Why it matters
Without understanding these typing styles, programmers might get confused about why some code works or fails. Structural typing allows more flexible code reuse and easier integration, while nominal typing enforces strict type identity for safety. Knowing the difference helps write better, safer, and more maintainable programs.
Where it fits
Before this, learners should know basic types and interfaces in TypeScript. After this, they can explore advanced type features like type guards, union types, and type inference.