# Bug Report <!-- Please fill in each section completely. Thank you! --> ### π Search Terms <!-- What search terms did you use when trying to find an existing bug report? List them here so people in the future can find this one more easily. --> ### π Version & Regression Information <!-- When did you start seeing this bug occur? `4.9.4` Please keep and fill in the line that best applies: --> - This is the behavior in every version I tried ### β― Playground Link <!-- A link to a TypeScript Playground "Share" link which shows this behavior https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgQwA4wLwzAUwO4wLLIA80ATgJZgDmANBgK5wBGmJAfABQCUA3ALABQiJADoImKOwDkCSbQCMPAaEiwEaeMmGVxUmYv5Lw0GGQgBBAGoIANmQAm6gEIgQ1zAjDsE+gWQBmMOwAhKaWNvacMADeAjBxMFAAFiQguACiJCkkUmAgMHp8-AC+AoYq+QDCIEgAngBc9Ews6giFvgHB3tGx8Ukp6Zkg2ZK5+ZKcAiUG-MrGCFW1AEwNYAzMJC2FQA --> [Playground link with relevant code](https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgQwA4wLwzAUwO4wLLIA80ATgJZgDmANBgK5wBGmJAfABQCUA3ALABQiJADoImKOwDkCSbQCMPAaEiwEaeMmGVxUmYv5Lw0GGQgBBAGoIANmQAm6gEIgQ1zAjDsE+gWQBmMOwAhKaWNvacMADeAjBxMFAAFiQguACiJCkkUmAgMHp8-AC+AoYq+QDCIEgAngBc9Ews6giFvgHB3tGx8Ukp6Zkg2ZK5+ZKcAiUG-MrGCFW1AEwNYAzMJC2FQA) ### π» Code ```js 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.