Repository: TypeScript
Issue: Issue with union type
Labels: Needs Investigation

<!-- 🚨 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.
-->

**TypeScript Version:**  3.7.5

**Expected behavior:**
Type of parameter qm in method Service.getItems should be union type assignable `QueryModel<KeyToEntityMap<E>>`

**Actual behavior:**
```
Argument of type 'QueryModel<KeyToEntityMap<E>>' is not assignable to parameter of type 'QueryModel<{ x: string; }> & QueryModel<{ y: string; }>'.
  Type 'QueryModel<KeyToEntityMap<E>>' is not assignable to type 'QueryModel<{ x: string; }>'.
    Type '{ x: string; }' is not assignable to type 'KeyToEntityMap<E>'.
```

**Code**
```ts
type Key = "a" | "b";
type KeyToEntityMap<E extends Key> =
    E extends "a" ? { x: string; } :
    E extends "b" ? { y: string; } :
    never;

class QueryModel<T>
{
    filters: [keyof T, string][] = [];
}

class Service<E extends Key>
{
    getItems(qm: QueryModel<KeyToEntityMap<E>>): KeyToEntityMap<E>[]
    {
        return [];
    }
}

type IServiceFactory = { [E in Key]: Service<E> };
class ServicesFactory implements IServiceFactory
{
    a: Service<"a"> = new Service<"a">();
    b: Service<"b"> = new Service<"b">();
}
const sf: IServiceFactory = new ServicesFactory();

class Same<E extends Key>
{
    fail(e: E)
    {
        let queryModel = new QueryModel<KeyToEntityMap<E>>();
        //Here getItems parameter gets wrong intersection type QueryModel<{ x: string; }> & QueryModel<{ y: string; }>
        let items: KeyToEntityMap<E> = sf[e].getItems(queryModel); 
    }
}

```



<details><summary><b>Output</b></summary>

```ts
"use strict";
class QueryModel {
    constructor() {
        this.filters = [];
    }
}
class Service {
    getItems(qm) {
        return [];
    }
}
class ServicesFactory {
    constructor() {
        this.a = new Service();
        this.b = new Service();
    }
}
const sf = new ServicesFactory();
class Same {
    fail(e) {
        let items = sf[e].getItems(new QueryModel());
    }
}

```


</details>


<details><summary><b>Compiler Options</b></summary>

```json
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "useDefineForClassFields": false,
    "alwaysStrict": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "downlevelIteration": false,
    "noEmitHelpers": false,
    "noLib": false,
    "noStrictGenericChecks": false,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "esModuleInterop": true,
    "preserveConstEnums": false,
    "removeComments": false,
    "skipLibCheck": false,
    "checkJs": false,
    "allowJs": false,
    "declaration": true,
    "experimentalDecorators": false,
    "emitDecoratorMetadata": false,
    "target": "ES2017",
    "module": "ESNext"
  }
}
```


</details>

**Playground Link:** [Provided](https://www.typescriptlang.org/play/?ssl=28&ssc=22&pln=28&pc=25#code/C4TwDgpgBA0hJQLxQEQEMVQD6oEYoG4AoUSWeAFQHsBRAO2AEtQBZNMAHhqggA9gIdACYBnciAB8SIlFlRufAcLHpMAfigBvKLwBcUEcABOjOgHMCUAL5RdMuQv6DRedVqgh9hk+cs27clB0EABuEEbERADGADZoImIAigCu4SAsVEIQMRwUEkSa9rIAZowxAkYi+gDaANbwVMVQFAA0BsamZgC61V1IUL3EVkTRcQlQAMrhIYxREFw8Tsri+YWBZhDAAJICALYiABQAjrv6KWkZWTlwINT0TKzsXBISAJT6N3cMzOlPNBK9IpaIGBIybZJGOgDLrEQLDYYkcDQLZTIwzOYAMTQUWAVCMCGQ2mq3FM4i6+lR6Pm-2sxFi8TElNmEBEWJxeIQjF2YBiEF2gmAYhR02ZbNx+IKQLQFJFcw4qikyGCAHdJrL5gqDq9YXJcDK0cz5fhFUEIKqmXKUMatUNolQ6IYDMV9MKDZjseKCabzerWR6OTaRvTxhM0PyFopnGIbqsgcU0GUDhB9DRXkC1oE5LzgFBmHyquIvg9fpwacgRMVqhAugA6DbbPaHFVQc74y7ZDifWjfR6ll5a7VQIHwohAA)