This PR implements KeysOfType<A extends object, B> which will return all the keys where the value extends a given one.
This can be useful to implement things like Clean<T> which removes from an object the keys where the value is never
type Clean<T> = Pick<T, Exclude<keyof T, KeysOfType<T, never>>>
type TestClean = Clean<{a: string, b: never}> // => {a: string}
another real world usage is to discriminate functions and value properties in objects:
type ObjectFunctions<T> = Pick<T, KeysOfType<T, Function>>
type ObjectProperties<T>= Pick<T, Exclude<keyof T, KeysOfType<T, Function>>>
This PR implements
KeysOfType<A extends object, B>
which will return all the keys where the value extends a given one. This can be useful to implement things likeClean<T>
which removes from an object the keys where the value isnever
another real world usage is to discriminate functions and value properties in objects: