Repository: TypeScript
Issue: there's an error occurred since I upgrade ts version to 4.6 or higher version
Labels: Needs Investigation

# Bug Report

when I upgrade the ts version of my local project to 4.6 or higher one, the error will be occurred.
```
Type '"subtype"' cannot be used to index type 'TokenMap[T]'.(2536)
```
but when I downgrade the version to 4.5(my local version is 4.2.4), there is none

### 🔎 Search Terms

<!--
  What search terms did you use when trying to find an existing bug report?
  List them here so people in the future can find this one more easily.
-->

### 🕗 Version & Regression Information

<!-- When did you start seeing this bug occur?

"Bugs" that have existed in TS for a long time are very likely to be FAQs; refer to
  https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs

If possible, please try testing the nightly version of TS to see if it's already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly

Note: The TypeScript Playground can be used to try older versions of TypeScript.

Please keep and fill in the line that best applies:
-->
- This changed between versions 4.6 and next 
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________

### ⏯ Playground Link
change version to 4.5.5,there is no error

<!--
  A link to a TypeScript Playground "Share" link which shows this behavior

  The TypeScript Workbench can be used for more complex setups, try
  https://www.typescriptlang.org/dev/bug-workbench/

  As a last resort, you can link to a repo, but these will be slower for us to investigate.
-->
[Playground link with relevant code](https://www.typescriptlang.org/play?ts=4.7.4#code/KYDwDg9gTgLgBDAnmYcAqEDWwB2cC8AUHHAD7pa4B0AchBGMWRdjlQPIpQCGOAJk3IZWVAGIBXHAGMYASwg5BLagGVxAIwCi4KEuHUAglADm4gLa4Yeym04AFKMGsjOASUUkhNjmDsQAzlaeymwA6gAWsjDAKmDcUk7B+mwAqjiYOBAA7oqEoJCwcDjcFv5xCSFwAN5MsjjRUABm8ajJAMIQZmYK1UwkAG7cADbiwABccIFQdcZMAL6ETPnQ8HUNzRV0DHCg0fz+IR1dPTUkJEgoE2jIwLT0jCQLJMuFa8BNLXCc77x8OyB7PgHdqdbp4U5nC7jdA3Hw-fh9SYaKFjRHBNTqa4oKhoXZo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1mxE-dLLq9YAcWAGBklfMArzQMcUJsG95IhABtABpAd0CXhSoQUgBdHerlng4s4tNeFYAfnQOAJhwYB+nJBY9Yn7hprgUfx5sSfp-nxZH5sIlQiiOEF0i8mCr3XtgRAEBGghEnvvGBz9V470PpLTuNFeCICxnAC+a9r633vkvCBUD4FgB3j-euyR-6AIgOIGAwDTLLzXnUOAhDoFPxIdHXAk9EHIKzqg6E6DMEXxvnfKMEwV6EDmAQ4AkDWEf2fqQvIME4BBwFubaeyCKE3AAe+ahtCBo3g1nAQYIxoRsKXmgHem9jGjF3pjZMak2bEPMaQ0m1cehqJnmREIlD3wugMUwaxpi5FgGcVY4YNid52JnJjPhHCcBcIsZvPhtjCCOLMRYxRgc3F4A8Ro7wRJ-EDHCUE1gYSTEpIwgJGJh5gBnziTmAaDi4kJKQRCIuatJZQjlIEuUfDMHcAOOgiRQA)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
type GetTokenMap<T extends Token> = {
  [K in T['type']]: T extends { type: K } ? T : never
}
type TokenMap = GetTokenMap<Token>

type TokenTypeWithSubType = {
  [K in keyof TokenMap]: TokenMap[K] extends { subtype: any } ? K : never
}[keyof TokenMap]

type TokenTypeWithoutSubType = {
  [K in keyof TokenMap]: TokenMap[K] extends { subtype: any } ? never : K
}[keyof TokenMap]

export function token<T extends TokenTypeWithoutSubType>(
  value: TokenMap[T]['value'],
  type: T,
): TokenMap[T]
export function token<T extends TokenTypeWithSubType>(
  value: TokenMap[T]['value'],
  type: T,
  subtype: TokenMap[T]['subtype'],
): TokenMap[T]
export function token<T extends Token.Type>(
  value: Token['value'],
  type: T,
  subtype?: Token.SubType,
): TokenMap[T] {
  return { type, value, subtype } as any
}
```

### 🙁 Actual behavior

alert error
### 🙂 Expected behavior

no error