Closed
Description
Bug Report
π Search Terms
mapped, generic, as clause
π Version & Regression Information
- This changed between versions 4.6.4 and 4.7.2/4.7.3
β― Playground Link
Playground link with relevant code
π» Code
The issue goes away if you remove the as Id<A>
in Obj
.
type Id<A> = A;
type Obj<A extends string> = {
[K in A as Id<A>]: null
}
declare const getObj: <A extends string>() => Obj<A>
const f = <A extends 'a'>(): null => {
const o = getObj<A>()
return o['a' as A]
}
π Actual behavior
1. Type 'Obj<A>[A]' is not assignable to type 'null'.
Type 'Obj<A>["a"]' is not assignable to type 'null'.
π Expected behavior
The compiler used to resolve o['a' as A]
as null
.