mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Accepting new baselines
This commit is contained in:
parent
6b61422e07
commit
edb6543354
42
tests/baselines/reference/unionTypeInference.js
Normal file
42
tests/baselines/reference/unionTypeInference.js
Normal file
@ -0,0 +1,42 @@
|
||||
//// [unionTypeInference.ts]
|
||||
// Verify that inferences made *to* a type parameter in a union type are secondary
|
||||
// to inferences made directly to that type parameter
|
||||
|
||||
function f<T>(x: T, y: string|T): T {
|
||||
return x;
|
||||
}
|
||||
function g<T>(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]);
|
||||
|
||||
|
||||
//// [unionTypeInference.js]
|
||||
// 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, y) {
|
||||
return x;
|
||||
}
|
||||
function g(value) {
|
||||
return value[1];
|
||||
}
|
||||
var a;
|
||||
var a = f(1, 2);
|
||||
var b;
|
||||
var b = f(1, "hello");
|
||||
var c;
|
||||
var c = f(1, a || "hello");
|
||||
var d;
|
||||
var d = f(undefined, "abc");
|
||||
var e;
|
||||
var e = g(["string", true]);
|
||||
72
tests/baselines/reference/unionTypeInference.types
Normal file
72
tests/baselines/reference/unionTypeInference.types
Normal file
@ -0,0 +1,72 @@
|
||||
=== tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts ===
|
||||
// Verify that inferences made *to* a type parameter in a union type are secondary
|
||||
// to inferences made directly to that type parameter
|
||||
|
||||
function f<T>(x: T, y: string|T): T {
|
||||
>f : <T>(x: T, y: string | T) => T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>y : string | T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return x;
|
||||
>x : T
|
||||
}
|
||||
function g<T>(value: [string, T]): T {
|
||||
>g : <T>(value: [string, T]) => T
|
||||
>T : T
|
||||
>value : [string, T]
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return value[1];
|
||||
>value[1] : T
|
||||
>value : [string, T]
|
||||
}
|
||||
|
||||
var a: number;
|
||||
>a : number
|
||||
|
||||
var a = f(1, 2);
|
||||
>a : number
|
||||
>f(1, 2) : number
|
||||
>f : <T>(x: T, y: string | T) => T
|
||||
|
||||
var b: number;
|
||||
>b : number
|
||||
|
||||
var b = f(1, "hello");
|
||||
>b : number
|
||||
>f(1, "hello") : number
|
||||
>f : <T>(x: T, y: string | T) => T
|
||||
|
||||
var c: number;
|
||||
>c : number
|
||||
|
||||
var c = f(1, a || "hello");
|
||||
>c : number
|
||||
>f(1, a || "hello") : number
|
||||
>f : <T>(x: T, y: string | T) => T
|
||||
>a || "hello" : string | number
|
||||
>a : number
|
||||
|
||||
var d: any;
|
||||
>d : any
|
||||
|
||||
var d = f(undefined, "abc");
|
||||
>d : any
|
||||
>f(undefined, "abc") : any
|
||||
>f : <T>(x: T, y: string | T) => T
|
||||
>undefined : undefined
|
||||
|
||||
var e: boolean;
|
||||
>e : boolean
|
||||
|
||||
var e = g(["string", true]);
|
||||
>e : boolean
|
||||
>g(["string", true]) : boolean
|
||||
>g : <T>(value: [string, T]) => T
|
||||
>["string", true] : [string, boolean]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user