Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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