Skip to content

Instantly share code, notes, and snippets.

@Kuniwak
Created December 16, 2018 14:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Kuniwak/bef0efc08ca9b6e36f8154b786502964 to your computer and use it in GitHub Desktop.
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