<!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨 Half of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common "Bugs" That Aren't Bugs section! Please help us by doing the following steps before logging an issue: * Search: https://github.com/Microsoft/TypeScript/search?type=Issues * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ Please fill in the *entire* template below. --> <!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. --> **TypeScript Version:** 3.5.2 <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** undefined, function arguments, variable, if condition, static code analysis **Code** ```ts const foo = (bar: number) => {}; const someOtherFunction = (bar?: number) => { const shouldCallFoo = !!bar; if (shouldCallFoo) { foo(bar); } } ``` **Expected behavior:** The code compiles without any problems **Actual behavior:** Error: ``` Argument of type 'number | undefined' is not assignable to parameter of type 'number'. Type 'undefined' is not assignable to type 'number'. ``` **Playground Link:** http://www.typescriptlang.org/play/#code/MYewdgzgLgBAZiEMC8MAUAjAhgJwFwxgCuAthgKY4CUKAfDAN4C+A3AFBuiSwQgnkB5KAAtKAMSJhgUAJbgU6bDgD8BYmUo1k9Bmxj6YXaDAjCQRADYATAMJYLFsYgVL2egzLjpT563YdOIDS6BqHwiJi4VOyhTGxMQA **Related Issues:** <!-- Did you find other bugs that looked similar? -->
TypeScript Version: 3.5.2
Search Terms: undefined, function arguments, variable, if condition, static code analysis
Code
Expected behavior:
The code compiles without any problems
Actual behavior:
Error:
Playground Link: http://www.typescriptlang.org/play/#code/MYewdgzgLgBAZiEMC8MAUAjAhgJwFwxgCuAthgKY4CUKAfDAN4C+A3AFBuiSwQgnkB5KAAtKAMSJhgUAJbgU6bDgD8BYmUo1k9Bmxj6YXaDAjCQRADYATAMJYLFsYgVL2egzLjpT563YdOIDS6BqHwiJi4VOyhTGxMQA
Related Issues: