If I have this interface:
interface Interface {
a: number
b: number
c: string
d: string
e: number[]
}
How would I get the keys of Interface
where the type of the value in Interface
is/extends a certain type? It's like Pick<T, K>
but instead of returning the keys that match a type it returns the keys whose values match a type.
I'm looking for something like this:
type KeyOfWhereValueMatches<T, U extends U[keyof U]> = // ???
KeyOfWhereValueMatches<Interface, number> // 'a' | 'b'
KeyOfWhereValueMatches<Interface, string> // 'c' | 'd'
KeyOfWhereValueMatches<Interface, number[]> // 'e'