I have these types:
type AUnion = 'A'|'AA'|'AAA'
type BUnion = 'B'|'Number'
type ValueType = {
'A': string;
'AA': string;
'AAA': string;
} | {
'B': string;
'Number': number;
}
I have a function receiveing two params, one is the value
and another is the message
:
const myFn = (value: ValueType, message: AUnion | BUnion) {
const mappingResult = value[message]
return mappingResult
}
When I do this mapping, the TS shows error that ‘A’ does not exist on type ValueType, how should I correct this type?