I want to make a generic type CompatibleProp<T, U> which would resolve to a string type containing all the properties of T that hold values of type U.
Example of what I want to achieve:
class C {
a: number;
b: string;
c: Date;
}
type DatePropOfC = PropCompatible<C, Date>; // "c"
type NumberOrStringPropOfC = PropCompatible<C, number | string>; // "a" | "b"
type AnyPropOfC = PropCompatible<C, any>; // same as keyof C
Is this possible to achieve with TypeScript 2.8 conditional types? I've tried a few combinations can't find the right one.