I don't expect real users to write code like this example. I just wanted to get this bug out of the way because I think it will make the solution to #27484 easier to understand.
TypeScript Version: master (85a3475)
Search Terms: mapped type parameter constraint instantiate
Code
type MyMap<T> = {[P in keyof T]: T[keyof T]};
function foo<U>(arg: U): MyMap<U> {
return arg;
}
Expected behavior: No error.
Actual behavior: Error:
Type 'U' is not assignable to type 'MyMap<U>'.
Type 'U[P]' is not assignable to type 'U[keyof U]'.
Type 'P' is not assignable to type 'keyof U'.
...
This is nonsense because P in keyof T and we set T = U.
Playground Link: link
Related Issues: none found