Repository: TypeScript
Issue: Discriminated union narrowing fails when use template literal types as tag
Labels: Suggestion,Awaiting More Feedback

<!-- 🚨 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.
-->

<!--
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.2.0-dev.20201211

<!-- Search terms you tried before logging this (so others can find this issue more easily) -->
**Search Terms:** narrowing, discriminated union, template literal types  

**Code**

```ts
type Types<T extends string> = {
  one: `${T}/one`;
  two: `${T}/two`;
}
type OneObj<T extends string> = {
  type: Types<T>["one"];
  one: string;
}
type TwoObj<T extends string> = {
  type: Types<T>["two"];
  two: string;
}
type OneOrTwoObj<T extends string> = OneObj<T> | TwoObj<T>

declare function acceptsOneObj<T extends string>(oneObj: OneObj<T>): void;
declare function acceptsTwoObj<T extends string>(twoObj: TwoObj<T>): void;

function f<T extends string>(oneOrTwoObj: OneOrTwoObj<T>, types: Types<T>){
  switch(oneOrTwoObj.type){
    case types.one:
     return acceptsOneObj(oneOrTwoObj); // Error: Argument of type 'OneOrTwoObj<T>' is not assignable to parameter of type 'OneObj<T>'.
    case types.two:
     return acceptsTwoObj(oneOrTwoObj); // Error: Argument of type 'OneOrTwoObj<T>' is not assignable to parameter of type 'OneObj<T>'.
  }
}

```

**Expected behavior:**
oneOrTwoObj should be narrowed to OneObj or TwoObj in function f

**Actual behavior:**
narrowing fails

**Playground Link:** <!-- A link to a TypeScript Playground "Share" link which demonstrates this behavior -->
[playground](https://www.typescriptlang.org/play?ts=4.2.0-dev.20201211#code/C4TwDgpgBAKuEGcA8MoQB7AgOwCYKgWACcBLbAcwD4oBeKAbwCgooB7bCALigAMASBjAC+Aeg4ReAbhZRgAdzY8BQsQrbSmwpk1CQoAeU4GARgCsUaTDnyES5anUay93WPGQwqAbQBEE3wBdGVYJHiIyShltV1hFUwtUDCw8AgiHGnpmVlceOEhPH191IJC5RXD7KK1deENjYhh480tkmzSqx3ojCASUGgAfOLY+rx1cCABjABsAQ2JoADMAV2xJ4FIOKFnJyYgwYAQe0asU23TKKgAKCQSeY5avAEoeADc2UlwZCZn5pdX1ptsNtdvtDk0Ro9Tu07JFqFd1HdhqMqC8oO9PjImCs1hstotWtZUrCMjcGhCkcdGs1ElQADRyDx5Dz9J7ZQjyUjASYACzJvWpkLMADpXGzZKxJrMENBXAhhWEJawFsBlsRgTs9gcjsZzPyDIKEk8pFBRKIoABRYjENjEHgAQWIFGWAFscMB2ItGfoAORUimPKg+qCkAjYNge6UIUgUbCzEzTWVsKBgeazN1YYie73QP262k+4VKqUynPy9RcJVQFVqjWg7UBsz6w3mY2m81Wm12qCO51u7Aethe2J5gWN-rB0NQcORhDR2PxxNyZOp4jpiCZ7Mjh4FousbTaJhmqAASR9Lu2CaT0-mNvkcggLrAcywUGmXIga+mIcOEGmiyLWIekJM4OjhTJ3AKfo-ACYJan0CEQJhC4ukgxBoOKRRSng6B-UUJDiRQiDgK8KAhkQsYmB+OYFigHFAS2TUwR1CACPOTprjCepWOeN4Pi+Kipho-5cSBEEtXBfCkiJdjwIRCphlZPjMR0ei8WBCg2LA0lbkFe5ySk+ky2ZKDnnZBBOW5PldIhcVWElaVZQ8BVOErezlQ3WtxOYnpm1sk1jwAORXG0rxdYtHLLUUKirGt1W8htFD8xQ2yCkK2DC2QDyYIA)

**Related Issues:** <!-- Did you find other bugs that looked similar? -->