Repository: TypeScript
Issue: Covariance breaks when checking for `undefinded` in a type
Labels: Needs Investigation

# Bug Report

I'm using the `solid-js` npm package which defines a type called `Setter`:
```ts
type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: (prev: T) => U) => U) & (<U extends T>(value: Exclude<U, Function>) => U) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
```
I don't fully understand the reasoning behind it, but it's giving me some problems:
```ts
type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: (prev: T) => U) => U) & (<U extends T>(value: Exclude<U, Function>) => U) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);

class A { a = 1 }
class B extends A { b = 2 }

type Test<T> = { 0: Setter<T> };

declare const a: Test<A>;
const b: Test<B> = a; // ERROR!
```
I created an object with the property `0` which contains a `Setter` and it appears to not be covariant.
Inspecting the error it looks like that the problem is originated from this part `undefined extends T ? () => undefined : {}`, infact if I remove it this works, moreover the problem would still occur if that was the only part of the type:
```ts
type Setter<T> = undefined extends T ? () => undefined : {};

class A { a = 1 }
class B extends A { b = 2 }

type Test<T> = { 0: Setter<T> };

declare const a: Test<A>;
const b: Test<B> = a; // ERROR!
```
I think it is an error because the types are the same:
```ts
type TA = Test<A>;
//   ^? type TA = { 0: {}; }
type TB = Test<B>;
//   ^? type TB = { 0: {}; }
```
Additionally if `Test` were to be defined as `[  Setter<T> ]` the error would not occur:
```ts
type Setter<T> = undefined extends T ? () => undefined : {};

class A { a = 1 }
class B extends A { b = 2 }

type Test<T> = [ Setter<T> ];

declare const a: Test<A>;
const b: Test<B> = a; // OK?!?!
```

### 🔎 Search Terms

- undefined extends T
- covariance
- covariant

### 🕗 Version & Regression Information

This changed between versions **3.3.3** and **3.5.1**. (The only playground version in which it doesn't occur is **3.3.3**)

### ⏯ Playground Link

[Playground Link](https://www.typescriptlang.org/play?#code/LAKFBcE8AcFMAIDKtzlgJwDwBUB88BeeACgFcA7AE1gDMBLc2S+WADzSoGd5t4B+EgEpC+CtXqNmALngBvAL7CAZCUwBVFu1hceuYgDcAhgBtSsGcWjpY+mdmEF8ah0+WqNbDpW54DJszIAoqwAxqbU6gA08ABiFCHgdAD25Lgu8M7wKsTqml4+ekam5vDBYaQRatFx5AnJqfAAPiSW1rY86c6dggDcoAD0-fBQcEgoaFh4hO552t66fsUWVjZ23SIZbjkeWjq+RQGloeGwUbHxiSlpG5nZuZ5zBYuHZSdnNXVXTS0r7fY3gm6fRAg2GMAQyFQGBw+CIYloDCYsz2-CEG3hEiRMgUwNAYUMnG4AEE5PBDNMAIzweR44wE7gAIWR8xJsngACNpgAmamgCDgniwTjgGHTNkABhkkImovkwNBIwQ2CFIqmRAA2mMoZN8ABdXEgaj46zwEIpYVkuwqzBE3DAs3kC3sq3CzAM2FknrwUGBABKvoA8r6AIR8kCKngkojK122+VDeDwAB6fH5o2wTOj1vd8cTyb4QA)

### 💻 Code

```ts
type Setter<T> = (undefined extends T ? () => undefined : {}) & (<U extends T>(value: (prev: T) => U) => U) & (<U extends T>(value: Exclude<U, Function>) => U) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
// type Setter<T> = (<U extends T>(value: (prev: T) => U) => U) & (<U extends T>(value: Exclude<U, Function>) => U) & (<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)) => U);
// type Setter<T> = undefined extends T ? () => undefined : {};

class A { a = 1 }
class B extends A { b = 2 }

type Test<T> = { 0: Setter<T> };
// type Test<T> = [ Setter<T> ];

declare const a: Test<A>;
const b: Test<B> = a; // ERROR!

type TA = Test<A>;
//   ^?
type TB = Test<B>;
//   ^?
```

### 🙁 Actual behavior

Can't assign `b` with the value of `a`.
It is wrong at the very least because it is not consistent

### 🙂 Expected behavior

Can assign `b` with the value of `a`