<!-- 🚨 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.1.0-dev.201xxxxx <!-- Search terms you tried before logging this (so others can find this issue more easily) --> **Search Terms:** null check, null check compilation **Code** ```ts declare const x: (() => void)|null; declare const ctor: Function; if (x instanceof ctor) { x(); } ``` **Expected behavior:** No compilation error since if x == null => true, then `x instanceof Function` => false **Actual behavior:** Cannot invoke an object which is possibly 'null'. const x: (() => void) | null **Playground Link:** http://www.typescriptlang.org/play/#src=declare%20const%20x%3A%20%7By%3A%20()%20%3D%3E%20%27hi%27%7Cnull%7D%3B%0D%0Adeclare%20const%20ctor%3A%20Function%3B%0D%0A%0D%0Aif%20(x.y%20instanceof%20ctor)%20%7B%0D%0A%20%20x.y()%3B%0D%0A%7D **Related Issues:** <!-- Did you find other bugs that looked similar? -->
Activity
joyzhong commentedon Sep 21, 2018
(Note that
strictNullChecksmust be enabled in Options)rolivegab commentedon Sep 22, 2018
The following code has no compile errors:
VSCode editor also points:

But i don't know really what any of that means