I would like to 'Omit' a property in an interface when another property within that same interface equals a certain value in an enum.
This however DictionaryValue['type'] extends FieldType.ARRAY always equals to false.
I don't want to make the property optional by default as this would possibly result to type errors in my code.
enum FieldType {
STRING,
NUMBER,
ARRAY
}
interface DictionaryValue {
type: FieldType,
value: number
}
interface Dictionary<T extends string> {
[key in T]: DictionaryValue['type'] extends FieldType.ARRAY ?
Omit< DictionaryValue, 'value'> :
DictionaryValue
}