Currently, I am working on the task of merging enum maps in my code. Here is what I have so far:
enum One {
a = 'a',
}
enum Two {
aa = 'aa',
}
enum Three {
aaa = 'aaa',
}
type unit = One | Two | Three;
const twoFromOne: Map<Two, One> = new Map([[Two.aa, One.a]]);
const threeFromTwo: Map<Three, Two> = new Map([[Three.aaa, Two.aa]]);
const combined: Map<unit, unit> = new Map([
...twoFromOne,
...threeFromTwo,
]);
However, upon running the code, I encountered an error from the typescript compiler:
const twoFromOne: Map<Two, One>
No overload matches this call.
Overload 1 of 3, '(iterable: Iterable<readonly [Two, One]>): Map<Two, One>', gave the following error.
Argument of type '([Two, One] | [Three, Two])[]' is not assignable to parameter of type 'Iterable<readonly [Two, One]>'.
The types returned by '[Symbol.iterator]().next(...)' are incompatible between these types.
...
I am struggling to comprehend this error message. Could it be suggesting that one map is being assigned into another instead of properly merging them?