Closed
Description
Bug Report
π Search Terms
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
Playground link with relevant code
π» Code
const map = new Map<string, number>();
map.set('a', 1);
const a = map.get('a');
const isAValid = Boolean(a);
if (!isAValid) {
throw Error('no a');
}
const aCopy: number = a;
if (!a) {
throw Error('no a')
}
const aCopy2: number = a;
π Actual behavior
In the first example aCopy gives error because it can be undefined according to typescript
π Expected behavior
aCopy should be defined to be a number.