#TypeScript: Does anyone know why and how to fix it?

I want new Map(arr1) to have the inferred(!) type Map<typeof Red | typeof Green, "RED" | "GREEN">
new Map(arr2) does have a nice inferred type, so this should be possible(?)

const Red = Symbol('Red');
const Green = Symbol('Green');
const arr1 = [
[Red, 'RED'],
[Green, 'GREEN'],
] as const;
new Map(arr1); // error

const arr2 = [
[0, 'RED'],
[1, 'GREEN'],
] as const;
new Map(arr2); // OK

https://www.typescriptlang.org/play/?target=2#code/MYewdgzgLgBASgUwCYwLwwMoE8C2AjEAGwAoByRJUgSgG4AoUSWAcQCcEEw1NcCTS2HMNXqNoMAIatWARm4BtOjBjyKAGhjkAogBFSAXTVKVgzhoFwtWgHIGj+yRBhio9MAgDuMALISADsRSsrQwAPShMAjSIKx0DODiQQBMCsbyAAzmlnqGaTLmzJY2dnQOEk4ubp4+-oHSSSHhMADyANJAA

TS Playground - An online editor for exploring TypeScript and JavaScript

The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.

@rauschma
If filing a bug with the TS team, this might be helpful to add.

const arr3 = [
[Red as typeof Red | typeof Green, 'RED'],
[Green as typeof Red | typeof Green, 'GREEN'],
] as const;
new Map(arr3); // OK

@MildlyAggrievedScientist Cool, thanks! Do you have a link?

I found a workaround:

type Key = (typeof arr1)[number][0];
new Map<Key, string>(arr1);

Inferring the Map key is important to me because I want to check statically if all cases were covered.

@rauschma Sorry. I just added that to the end of your playground window and it didn't bother to create a new link from it.
@MildlyAggrievedScientist My bad, I misread and thought you had written “I filed a bug with the TS team”. That’s the link I was interested in. 🙈