I have the following code:
type ValidationResult = 'OK' | 'MISSING_FIELDS' | 'DUPLICATED_FIELD';
type ValidationResultOkDetails = null;
type ValidationResultMissingFieldsDetails = [string];
type ValidationResultDuplicatedField = string;
type Validation = {
result: ValidationResult,
details: any
}
Is there a way in Typescript to tell the compiler that when the field result of Validation is 'OK', details is of type ValidationResultOkDetails, when it is 'MISSING_FIELDS', details should be ValidationResultMissingFieldsDetails and so on?