Aliases with the Structural Behavior of TypeScript
This lesson demonstrates the fundamental aspect of TypeScript to rely on objects' structures.
The structural nature of TypeScript
TypeScript is a structural language and not a nominal language. This means that TypeScript compares the structure and not the name of an object to determine if the objects are similar.
The following code has a function that takes an anonymous type that has a property name
. The example has three ways to call the function:
- interface
- type
- anonymous