nominal typing
A type system in which two types are compatible only if one is declared to inherit or implement the other, not merely because they have the same members.
In more detail
Under nominal rules, two classes with identical members are still unrelated types. Languages such as C# and Java are nominal, while TypeScript compares shapes and is structural.
Related terms
- static typing — A language rule that every variable has one fixed type, known when the program is compiled, so type mistakes are caught before it runs.
- interface — A named set of member signatures that a type promises to implement, with no state of its own.
- inheritance — Declaring one class or type as a specialised version of another, so it receives the parent's members and can be used wherever the parent is expected.
- structural typing — A type rule where two types are compatible if they have the same shape, whatever they are called.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript