Repository: TypeScript
Issue: Type discrimination broken on generic, mapped type values when `strictNullChecks:false`
Labels: Bug

<!-- 🚨 STOP 🚨 STOP 🚨 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.
-->
Running into what I think is a bug with type discrimination of a function when you have a mapped type on a generic type .  I've tried to make the reproduction as simple as possible.
<!--
Please try to reproduce the issue with the latest published version. It may have already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly
-->
**TypeScript Version:**  4.1.0-beta

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:**
discrimination, generic, mapped type, strictNullChecks off

**Code**

```ts
type Mapping<T> = { [key in keyof T]?: string | (() => string) };

function foo<T>(mapping: Mapping<T>) {
    const results: {[key: string]: string} = {};
    for (const key in mapping) {
      const valueTransform = mapping[key];
      if (typeof valueTransform === 'function') {
        results[key] = valueTransform(); //! This expression is not callable...
      } else if(typeof valueTransform === 'string') {
        results[key] = valueTransform;
      }
    }
    return results;
}
```

**Expected behavior:**

**Actual behavior:**
`strictNullChecks:false` I get the following error:
```
This expression is not callable.
  Not all constituents of type 'string | (() => string)' are callable.
    Type 'string' has no call signatures.
```

If you change it back to `true`, it will work as expected.  It seems to have something to do with the combination of generics & mapped types, as if you change to reference `Foo` directly the code will compile.

`type Mapping<T> = { [key in keyof Foo]?: string | (() => string) };`

Also the discrimination only seems to break on the `typeof valueTransform === 'function'`

**Playground Link:** [Playground Link](https://www.typescriptlang.org/play?noImplicitAny=false&strictNullChecks=false&ts=4.1.0-beta#code/LAKFBcE8AcFMAICyBDa0CWA7A5gHgCoB88AvPAN7wDaA1rJPFvHZAPYBm8+AugPwBc8AM7gATlmzwAPvAAUsgJSliI8TiUBfANyhQ7AK6YAxuHStM8dq1YFCsgLaoMOQSjQTbS8qHi-4R8xF4UVghfQAbcCFBclp6QVUJbgSxCQ1SCm0fPytROQDMIJZGC0d3dQpsv39A8HgAN2Rw-Vh8UWRC3PsMsudsOMhuHRBq33ROWSg4DgamlraOoS7SEjIAcgNjU3M1ryrRkLDIoQHuDMbm1vbO1lF7RWHR+HTYcKEEccmYWBmL+eulrduqt1okcLtKiMnsFQhEoqdznMrosuo9Rhp9hiob4QuB9KILIc4UJhljQAB6cnwWAAD2Q9mg4QQQgAFqwAO4SeDgFnIOroOrs240ISMThsfQwxnIIwIHkIbCwTCwcRGErclkfTAAE1pzHoEG+8AAYtYMpQrKwUmpsAAaeAAI2QomtaWGhrgSCcEgATLZzdRikwWDNTaw+K6cNI5IplMJUhUsmAQJsTGYLJa-UQHN6XF7ytgs4Q9tiaoU6kTjjEBpHsMl4zb0mRyEnqrl8rV9QwmL0JCWngUgn9kTc7j1c-0WEN9mMJlMfpxhwtR8DVvANoY0zt+9DK-Cp4jLsvAXcHjPntS3h92F9poukcfliD12DsBDvKXqnuTgeyEuAai55YtUwF+Li+KErCxykkAA)



**Related Issues:** <!-- Did you find other bugs that looked similar? -->
https://github.com/microsoft/TypeScript/issues/27470