You cannot have the same two keys in map. Once you have tried to write a value with the same key, it will override previous value. What I mean:

If you want to check if a Map contains some key before writing it to it, you can just use Map.has method:
if (map.has(key)) throw new Error(`Map is already contains key: "${key}"`)