diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts b/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts new file mode 100644 index 00000000000..a4b5edba9eb --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts @@ -0,0 +1,20 @@ +// Verify that inferences made *to* a type parameter in a union type are secondary +// to inferences made directly to that type parameter + +function f(x: T, y: string|T): T { + return x; +} +function g(value: [string, T]): T { + return value[1]; +} + +var a: number; +var a = f(1, 2); +var b: number; +var b = f(1, "hello"); +var c: number; +var c = f(1, a || "hello"); +var d: any; +var d = f(undefined, "abc"); +var e: boolean; +var e = g(["string", true]);