I have a situation where I have an array of objects containing a value that must be a key of some other type. The simplest version is something like this:
interface Object<T> {
name: keyof T
}
type ArrayOfObjects<T> = Object<T>[];
function f<T>(arr: ArrayOfObjects<T>){
//...
}
This is really nice because it allows me to check that any values I pass in the object array have a valid "name" that corresponds to a key of type T.
Is there any way to also ensure that every key of type T is included in at least one object in the array arr
as the value corresponding to name
?