I'm trying to merge enum maps, the code runs:
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,
]);
but I get a typescript compiler error:
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 don't understand the error, is it saying one map is being assigned into another instead of a merge?