knowledge
knowledge copied to clipboard
Advanced TypeScript types
Proposal
- Differences between classes, interfaces and type aliases.
- Literal and enum-member types.
- Intersection and union types.
- Type guards based on type discriminants, duck typing,
typeof
andinstanceof
. - Index signatures and mapped types.
- Type-generic interfaces, type aliases and functions.
Take away
Developers should be aware of Typescript's more advanced typing capabilities, understand the basics of how they work and in which cases they can be utilized for improved type-safety and IDE intellisense.
In particular, they should understand:
- generic types and functions,
- type guards (particularly when combined with strict null checks),
- unions and discriminated union pattern,
- mapped types and
keyof
type.