Advanced types with generics
The TypeScript compiler already gives us a large toolbox in order to define custom types, inherit types from each other, and use generic syntax to describe how our code is expecting to use these types. By combining these language features, we can start to describe some seriously advanced type definitions, including types based on other types, or types based on some or all of the properties of another type. By using some new TypeScript keywords, and applying some well-known language features, we can also start to query a type for its properties, check to see whether a type has certain properties, or completely modify a type by adding or removing properties as we see fit. Welcome to the mind-bending world of conditional ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access