Is there a way in TypeScript to restrict the possible values of an object based on specific conditions? Here is my idea:
interface IObject = {
key1: string;
key2: string;
key3: "A" | null;
key4: (if key3 is 'A' then allow 'value1' or 'value2', else if it is null then allow "value3" or "value4")
}
Can TypeScript handle this kind of restriction?