Generic and keyof
This lesson explains how to combine keyof with generic.
You can use extends
to extend a generic type to another type if you want the generic type to be a subset of the other type.
In the following code, we see that line 13 expects that the generic K
extends T
, which means that the second parameter needs to extend the former.
Get hands-on with 1200+ tech skills courses.