Is there some way to have TypeScript understand that the value retrieved from this map is not undefined
?
const stringToDecimal = new Map<string, number>([
["one", 1],
["two", 2],
]);
console.log(stringToDecimal.get("one") + 5); // Error about being possibly undefined
It seems you can't use const assertions with Map, and also ReadonlyMap
didn't work.