Is it possible to set a property type based on the property value?
For example, if the command is:
- If 'set' then the payload must be PayloadSet
- If 'put' then the payload must be PayloadPut
- If 'del' then the payload must be PayloadDel
Currently, the closest solution I have found is:
export interface Command {
command: 'set' | 'put' | 'del';
payload: PayloadSet | PayloadPut | PayloadDel;
}
However, this allows the user to set a command and input an incorrect payload.