Type Argument Constraints
This lesson talks about generic type argument constraints.
We'll cover the following
Overview
Sometimes it makes sense to put some restrictions on type arguments. Having these restrictions allows you to make assumptions about the type argument when referring to it inside some function.
You can express the restriction using the extends
keyword. For example, you might decide to enforce the fact that FormField
should only contain string
, number
, or boolean
values.
Get hands-on with 1400+ tech skills courses.