Add tests

This commit is contained in:
Anders Hejlsberg
2018-12-05 15:20:21 -08:00
parent 2f7cf9e26c
commit 4ae0848bd4

View File

@@ -0,0 +1,21 @@
// @strict: true
// Repro from #28862
type Foo<A> = { type: "foo", (): A[] };
type Bar<A> = { type: "bar", (): A };
type FooBar<A> = Foo<A> | Bar<A>;
type InferA<T> = T extends FooBar<infer A> ? A : never;
type FooA = InferA<Foo<number>>; // number
// Repro from #28862
type Item<T> = { kind: 'a', data: T } | { kind: 'b', data: T[] };
declare function foo<T>(item: Item<T>): T;
let x1 = foo({ kind: 'a', data: 42 }); // number
let x2 = foo({ kind: 'b', data: [1, 2] }); // number