Aliases with the Structural Behavior of TypeScript
Explore the structural nature of TypeScript by learning how aliases work to simplify type definitions. Understand that TypeScript checks object structure rather than names, allowing flexible and compatible object usage in functions. This lesson helps you grasp how to improve code readability and reduce redundancy through structural contracts.
We'll cover the following...
We'll cover the following...
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