Here is my interface:
interface Responses {
200:{
foo:number;
};
204:{
bar:number;
};
}
I can get any of the property type as follow:
type TypeFor200 = Responses['200'];
However I would like to make it conditional so that if 200 property is not exist in the interface, it should return the type for 204, something like this:
type AnyType= Responses extends 200 ? Responses['200'] : Responses['204'] ;
If both 200 and 204 exist, the above example will work, otherwise will throw an error complaining that the property does not exist.
Note that I cannot make a change to Responses interface since it is in an autogenerated file.
How should I go about doing this?