I\'m trying to understand why TypeScript is giving me the following error: Object is possibly \'undefined\'
Object is possibly \'undefined\'
Here\'s the code snippet:
If you query for a key not in the map, you will get undefined. Not because the map holds an undefined value, but because it does not hold a value at all.
Try
results.get(key)!
Or
results.get(key) as number