Advanced Typescript
Get familiar with some of Typescript's greatest advanced features.
Typescript is awesome. It offers so many great features. Here’s a summary of some of the greatest advanced Typescript features.
- Union and intersection types
- Keyof
- Typeof
- Conditional types
- Utility types
- Infer type
- Mapped types
By the end of this blog post, you should have a base understanding of each of those operators and you should be able to use them in your projects.
Union and intersection types
Typescript allows us to combine multiple types to create a new type. This approach is similar to logical expressions in JavaScript where we can use the logical OR ||
or the logical AND &&
to create new powerful checks.
Union types
A union type is similar to Javascripts OR expression. It allows you to use two or more types (union members) to form a new type that may be any of those types.