TypeScript - Templates
When creating more reusable parts of your code, the result types start to have a similar structure. To create generic templates of types, you can use a template system.
With this TypeScript feature, you will be able to create reusable types that will automatically adjust to the inputs and make your typing system more flexible in the future.
Basic template type
I know how to create a basic template type accepting generic type and creating type using passed type
I know how to make passed type option using default type
Constain template value
I know that I can contain template values using the extends keyword and a more strict type as the base
Relation between arguments
I know that I can limit the types passed inside template arguments based on the previous types – e.g., limiting the second argument to keys of the first one
Conditional types
I know that I can create conditional types using extends and ternary operator
I know this syntax is mostly useful inside template types
I know how to create a basic template type accepting generic type and creating type using passed type
I know how to make passed type option using default type
I know that I can contain template values using the extends keyword and a more strict type as the base
I know that I can limit the types passed inside template arguments based on the previous types – e.g., limiting the second argument to keys of the first one
I know that I can create conditional types using extends and ternary operator
I know this syntax is mostly useful inside template types