|
|
|
|
|
by skywal_l
1712 days ago
|
|
type Ensure
I define a type called Ensure <T, K extends keyof T>
This type takes two type parameters, one called T and the other K which will consist of Keys belonging to the type T (in our case, "foo", "bar" or "baz"). = T &
This new type (called Ensure) will be equal to the union of two types: One will be T and the other will be: { [U in keyof Pick<T, K>]
A new type which keys will be picked among the key listed in K -?
To which we will remove the potential optional qualifier : T[U] };
And which types will be the same as in T. |
|