Repository: TypeScript
Issue: v4.7 and above stopped supporting a type pattern that used to work in v4.6 (Key Remapping in Mapped Type)
Labels: Needs Investigation

# Bug Report

In version 4.7 and above a patter (`[P in TName as P]:`) causes types to break. It's really strange, since it does work if used in some ways, but if used to pass down to a method argument, it will result in type `unknown`.

See playground links for examples.

### 🕗 Version & Regression Information

A friendly person in the comments of [my original stackoverflow question](https://stackoverflow.com/questions/74017852/what-breaking-change-caused-my-ts-types-to-break-in-ts-4-7-and-above-worked-in) comments narrowed it down to this: [between 2022-03-15 and 2022-03-16](https://github.com/microsoft/TypeScript/search?q=merged%3A2022-03-15..2022-03-16&type=issues)


### ⏯ Playground Link

[TS 4.7](https://www.typescriptlang.org/play?ts=4.7.4#code/C4TwDgpgBAYglhANgEwGoENEFcIGcoC8UAShAMYD2ATsgDy7BVwB2A5gDRTrMgB8A3AChBoSCQis4DCFQDyYYHArNctACrwkaTDigQAHsAjNk+bn0JQACuiqLMtAN6CorqAFsIwABYVkALigACgA3HQhAjQQUDGwIAEpCXigQijhkITcoXDh3MEQIWJxIzRjwoQBfXmFRaFLTKyoKMFoXNyitIrw9Q2NTWGjtONx2Ntc1ADl0Tx6jE3wAawgQCgAzKA6y4bGoZKJnLKyAbSsoFg2pmfR8KwBdQNl3OGBWw7fxSWk5BSUVdXqurgTrdeKN3ocAERhOIAQVwEyw7gARjIIVAAD5QKHhOEAEXQRjRmIhuC8XThRKxyCk6CRBWQEJ2WQEOwqQmENXA0FInyMVHqjWaqk2Qxw+AMc36APCuD2UAObkozEYFEQJUGgMyblWg1wgXquEFLRFgM4SxW6xNMpZbOESoYHykfINln+Gplsz6+Glw14QQVrh1WhGOyVKsQowqgR5TpkAqaYGFPrFvESBGSjigtsE9uAGwAogBlNSWGNfA3+nZBlB6nYBw5GBiBevgzw+PyBILMCAAd1iAEY0xms5wAPSjqDdvuYfvZXxYFBQFFQWqTxEoqhM97j7K5fKFcKBCG1AD6DCYbBPzAowBPmEQFB7EAZY4nqywzGYcEQID016wrDeJwPhSFAPbUAs+BgAmMg-lurgVGC7yNsAABMzbwYcba+AEwRTrEqFDvKI5QDu+GYKhc4UAuyBLtAq7niwrCYRUrJIa4YZNGqxEoYEACcfHAXgaFHqsFAUEithohUpETiB+CgT23gyPRykrly+C4POi6sF4ZzMKsMhUM+UCrE07iCBU8RAA)
[TS 4.6](https://www.typescriptlang.org/play?ts=4.6.4#code/C4TwDgpgBAYglhANgEwGoENEFcIGcoC8UAShAMYD2ATsgDy7BVwB2A5gDRTrMgB8A3AChBoSCQis4DCFQDyYYHArNctACrwkaTDigQAHsAjNk+bn0JQACuiqLMtAN6CorqAFsIwABYVkALigACgA3HQhAjQQUDGwIAEpCXigQijhkIQBfXmFRaE0UXCsqCjBaFzcorVicfAMjE3wC7TjcdgrXNQA5dE89Q2NTKABrCBAKADMoKpjw3A6oZKJnN1WoAG0rKBZpnr70fCsAXUDZdzhgcrXr8UlpOQUlFXVmmrxNo952m7WAIjC4gBBXBdLDuABGMl+UAAPlB-uFgQARdBGaFw364LxvYHo+HIKTocGICDIX4LVYCBaZITCXLgaCkO5GKjNYqlVQzFq1foNIavOZLKArNyUZiMCiISIC1pCVYTaKmQLNIolMpct5tEZjSbTGW1Kk04Rihi3KQslWWF6KzW8wZNG2CoIi1wKrRtBZiiWIdqZQJM80yNlqzn6vC8RIEZKOKBGwQm4DTACiAGU1JYA-cVc6Fm7Cv4Fi61kYGIEiz9PD4-IEgswIAB3WIARkj0djnAA9B2oHXG5gm1BcL4sCgoJCoHke2DIVQKW5Mt8biXgAAmMtz66V3wBYK92Ir1vC9tQLs9hv7wfD0fjycMJhsDex6mL1xekpSo-LwIATm-nGXa7whMFAUOCtjQpkJ7dj4UjbPg9beDI0A+MhDL4EOFAjsgUCsF42zMBMMhUKSUATCU7iCJk8RAA)

### 💻 Code

The issue was caused by the following types:
```
[P in TName as P]:
```
which does not work anymore in v4.7 and needs to be
```
[P in TName]:
```
(I had it like this, because I used to exclude a type like this: `[P in TName as P extends UnacceptedPaths ? never : P]:`)

### 🙁 Actual behavior

One of the nested types receives type `unknown` to it's params, when it should be properly inferred from the code.

### 🙂 Expected behavior

Should work like in v4.6 - type should be inferred. If I remember correctly, I came up with the problematic type from [this](https://stackoverflow.com/a/63990350/9191773).