This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { a: "a" = "a"; } | |
class B { b: "b" = "b"; } | |
interface X { | |
a: Y<A>; | |
b: Y<B>; | |
} | |
interface Y<T> { t: T; } | |
type Z<T> = { [key in "a"]: Y<T> }; | |
function w<T>(z: Z<T>): T { | |
return z.a.t; | |
} | |
const z1: X = null as any; | |
// The type of z2 should be inferred to A (but not). | |
const z2 = w(z1); // z2: any | |
const z3 = w<A>(z1); // z3: A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment