From da2efa05d7fa713f0b48e329d655f36d9810e044 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 6 Sep 2016 17:32:46 -0700 Subject: [PATCH] Accept new baselines --- ...GenericFunctionWithZeroTypeArguments.types | 10 ++--- ...WithoutReturnTypeAnnotationInference.types | 2 +- ...defaultBestCommonTypesHaveDecls.errors.txt | 4 +- .../exportDefaultAsyncFunction2.types | 2 +- .../reference/extendBooleanInterface.types | 4 +- .../reference/extendNumberInterface.types | 4 +- .../reference/extendStringInterface.types | 4 +- ...erInSignatureWithRestParameters.errors.txt | 4 +- .../reference/functionImplementations.types | 4 +- .../genericCallTypeArgumentInference.types | 12 +++--- ...cCallWithFunctionTypedArguments.errors.txt | 20 ++++----- ...CallWithFunctionTypedArguments2.errors.txt | 8 ++-- ...ithFunctionTypedMemberArguments.errors.txt | 16 +++---- .../reference/genericFunctions1.types | 2 +- .../reference/genericRestArgs.errors.txt | 8 ++-- .../reference/maxConstraints.errors.txt | 4 +- .../reference/noImplicitReturnsInAsync1.types | 4 +- .../parenthesizedContexualTyping2.types | 24 +++++------ .../reference/parser15.4.4.14-9-2.errors.txt | 4 +- .../taggedTemplateContextualTyping1.types | 4 +- ...ateStringsTypeArgumentInference.errors.txt | 4 +- ...StringsTypeArgumentInferenceES6.errors.txt | 4 +- ...rgedInterfacesWithDifferingOverloads.types | 2 +- ...gedInterfacesWithDifferingOverloads2.types | 2 +- .../typeArgInference2WithError.errors.txt | 4 +- .../typeArgumentInference.errors.txt | 4 +- ...entInferenceConstructSignatures.errors.txt | 4 +- ...rgumentInferenceWithConstraints.errors.txt | 4 +- ...umentInferenceWithObjectLiteral.errors.txt | 7 ++- ...eInferenceConflictingCandidates.errors.txt | 4 +- ...peParameterAsTypeParameterConstraint.types | 6 +-- ...sTypeParameterConstraintTransitively.types | 2 +- ...TypeParameterConstraintTransitively2.types | 2 +- .../undefinedInferentialTyping.types | 2 +- .../reference/unionTypeInference.errors.txt | 43 +++++++++++++++++++ .../wrappedAndRecursiveConstraints3.types | 2 +- 36 files changed, 144 insertions(+), 96 deletions(-) create mode 100644 tests/baselines/reference/unionTypeInference.errors.txt diff --git a/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types b/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types index ff4bbae23b7..99fc2d955d1 100644 --- a/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types +++ b/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types @@ -11,7 +11,7 @@ function f(x: T): T { return null; } var r = f(1); >r : number ->f(1) : number +>f(1) : 1 >f : (x: T) => T >1 : 1 @@ -26,7 +26,7 @@ var f2 = (x: T): T => { return null; } var r2 = f2(1); >r2 : number ->f2(1) : number +>f2(1) : 1 >f2 : (x: T) => T >1 : 1 @@ -39,7 +39,7 @@ var f3: { (x: T): T; } var r3 = f3(1); >r3 : number ->f3(1) : number +>f3(1) : 1 >f3 : (x: T) => T >1 : 1 @@ -59,7 +59,7 @@ class C { } var r4 = (new C()).f(1); >r4 : number ->(new C()).f(1) : number +>(new C()).f(1) : 1 >(new C()).f : (x: T) => T >(new C()) : C >new C() : C @@ -83,7 +83,7 @@ var i: I; var r5 = i.f(1); >r5 : number ->i.f(1) : number +>i.f(1) : 1 >i.f : (x: T) => T >i : I >f : (x: T) => T diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types index a714644ac7c..0b515750aec 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -54,7 +54,7 @@ function foo4(x: T) { } var r4 = foo4(1); >r4 : number ->foo4(1) : number +>foo4(1) : 1 >foo4 : (x: T) => T >1 : 1 diff --git a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt index 5000ae05cc3..3b81fe0864e 100644 --- a/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt +++ b/tests/baselines/reference/defaultBestCommonTypesHaveDecls.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(2,6): error TS2339: Property 'length' does not exist on type '{}'. tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(5,6): error TS2339: Property 'length' does not exist on type 'Object'. tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. ==== tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts (3 errors) ==== @@ -19,7 +19,7 @@ tests/cases/compiler/defaultBestCommonTypesHaveDecls.ts(8,14): error TS2453: The var result = concat(1, ""); // error ~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. var elementCount = result.length; function concat2(x: T, y: U) { return null; } diff --git a/tests/baselines/reference/exportDefaultAsyncFunction2.types b/tests/baselines/reference/exportDefaultAsyncFunction2.types index baa41a10532..a9ff903e53a 100644 --- a/tests/baselines/reference/exportDefaultAsyncFunction2.types +++ b/tests/baselines/reference/exportDefaultAsyncFunction2.types @@ -20,7 +20,7 @@ export default async(() => await(Promise.resolve(1))); >() => await(Promise.resolve(1)) : () => any >await(Promise.resolve(1)) : any >await : (...args: any[]) => any ->Promise.resolve(1) : Promise<1> +>Promise.resolve(1) : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } diff --git a/tests/baselines/reference/extendBooleanInterface.types b/tests/baselines/reference/extendBooleanInterface.types index 1230846c7ce..03187040259 100644 --- a/tests/baselines/reference/extendBooleanInterface.types +++ b/tests/baselines/reference/extendBooleanInterface.types @@ -26,7 +26,7 @@ var a: string = x.doStuff(); var b: string = x.doOtherStuff('hm'); >b : string ->x.doOtherStuff('hm') : string +>x.doOtherStuff('hm') : "hm" >x.doOtherStuff : (x: T) => T >x : true >doOtherStuff : (x: T) => T @@ -41,7 +41,7 @@ var c: string = x['doStuff'](); var d: string = x['doOtherStuff']('hm'); >d : string ->x['doOtherStuff']('hm') : string +>x['doOtherStuff']('hm') : "hm" >x['doOtherStuff'] : (x: T) => T >x : true >'doOtherStuff' : "doOtherStuff" diff --git a/tests/baselines/reference/extendNumberInterface.types b/tests/baselines/reference/extendNumberInterface.types index f96ead3d794..a6ba453894e 100644 --- a/tests/baselines/reference/extendNumberInterface.types +++ b/tests/baselines/reference/extendNumberInterface.types @@ -26,7 +26,7 @@ var a: string = x.doStuff(); var b: string = x.doOtherStuff('hm'); >b : string ->x.doOtherStuff('hm') : string +>x.doOtherStuff('hm') : "hm" >x.doOtherStuff : (x: T) => T >x : number >doOtherStuff : (x: T) => T @@ -41,7 +41,7 @@ var c: string = x['doStuff'](); var d: string = x['doOtherStuff']('hm'); >d : string ->x['doOtherStuff']('hm') : string +>x['doOtherStuff']('hm') : "hm" >x['doOtherStuff'] : (x: T) => T >x : number >'doOtherStuff' : "doOtherStuff" diff --git a/tests/baselines/reference/extendStringInterface.types b/tests/baselines/reference/extendStringInterface.types index 5b3b5c6b9ea..428624dc57f 100644 --- a/tests/baselines/reference/extendStringInterface.types +++ b/tests/baselines/reference/extendStringInterface.types @@ -26,7 +26,7 @@ var a: string = x.doStuff(); var b: string = x.doOtherStuff('hm'); >b : string ->x.doOtherStuff('hm') : string +>x.doOtherStuff('hm') : "hm" >x.doOtherStuff : (x: T) => T >x : string >doOtherStuff : (x: T) => T @@ -41,7 +41,7 @@ var c: string = x['doStuff'](); var d: string = x['doOtherStuff']('hm'); >d : string ->x['doOtherStuff']('hm') : string +>x['doOtherStuff']('hm') : "hm" >x['doOtherStuff'] : (x: T) => T >x : string >'doOtherStuff' : "doOtherStuff" diff --git a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt index 3666c89a0ed..e1cde0c1632 100644 --- a/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt +++ b/tests/baselines/reference/fixTypeParameterInSignatureWithRestParameters.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. ==== tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/fixTypeParameterInSignatureWithRestParameters.ts(2,1): erro bar(1, ""); // Should be ok ~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. \ No newline at end of file +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index 683c4c8ea5f..d81b02598bd 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -139,7 +139,7 @@ var un = function () { // FunctionExpression with no return type annotation and returns a type parameter type var n = function (x: T) { >n : number ->function (x: T) { return x;} (4) : number +>function (x: T) { return x;} (4) : 4 >function (x: T) { return x;} : (x: T) => T >T : T >x : T @@ -154,7 +154,7 @@ var n = function (x: T) { // FunctionExpression with no return type annotation and returns a constrained type parameter type var n = function (x: T) { >n : number ->function (x: T) { return x;} (4) : number +>function (x: T) { return x;} (4) : 4 >function (x: T) { return x;} : (x: T) => T >T : T >x : T diff --git a/tests/baselines/reference/genericCallTypeArgumentInference.types b/tests/baselines/reference/genericCallTypeArgumentInference.types index f9b01f1be86..33c38b0dd48 100644 --- a/tests/baselines/reference/genericCallTypeArgumentInference.types +++ b/tests/baselines/reference/genericCallTypeArgumentInference.types @@ -13,7 +13,7 @@ function foo(t: T) { var r = foo(''); // string >r : string ->foo('') : string +>foo('') : "" >foo : (t: T) => T >'' : "" @@ -47,7 +47,7 @@ function foo2b(u: U) { var r2 = foo2('', 1); // number >r2 : number ->foo2('', 1) : number +>foo2('', 1) : 1 >foo2 : (t: T, u: U) => U >'' : "" >1 : 1 @@ -198,7 +198,7 @@ var r5 = c.foo2('', 1); // number var r6 = c.foo3(true, 1); // boolean >r6 : boolean ->c.foo3(true, 1) : boolean +>c.foo3(true, 1) : true >c.foo3 : (t: T, u: number) => T >c : C >foo3 : (t: T, u: number) => T @@ -216,7 +216,7 @@ var r7 = c.foo4('', true); // string var r8 = c.foo5(true, 1); // boolean >r8 : boolean ->c.foo5(true, 1) : boolean +>c.foo5(true, 1) : true >c.foo5 : (t: T, u: U) => T >c : C >foo5 : (t: T, u: U) => T @@ -345,7 +345,7 @@ var r5 = i.foo2('', 1); // number var r6 = i.foo3(true, 1); // boolean >r6 : boolean ->i.foo3(true, 1) : boolean +>i.foo3(true, 1) : true >i.foo3 : (t: T, u: number) => T >i : I >foo3 : (t: T, u: number) => T @@ -363,7 +363,7 @@ var r7 = i.foo4('', true); // string var r8 = i.foo5(true, 1); // boolean >r8 : boolean ->i.foo5(true, 1) : boolean +>i.foo5(true, 1) : true >i.foo5 : (t: T, u: U) => T >i : I >foo5 : (t: T, u: U) => T diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt index 093c4bed545..80b04c069d5 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(26,10): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,16): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,15): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts (5 errors) ==== @@ -39,26 +39,26 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun var r8 = foo3(1, function (a) { return '' }, 1); // error ~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. var r9 = foo3(1, (a) => '', ''); // string function other(t: T, u: U) { var r10 = foo2(1, (x: T) => ''); // error ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. var r10 = foo2(1, (x) => ''); // string var r11 = foo3(1, (x: T) => '', ''); // error ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. var r11b = foo3(1, (x: T) => '', 1); // error ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. var r12 = foo3(1, function (a) { return '' }, 1); // error ~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt index 3a397a66eba..90f87de070d 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments2.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(29,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts(40,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments2.ts (2 errors) ==== @@ -36,7 +36,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun var r4 = foo2(1, i2); // error ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. var r4b = foo2(1, a); // any var r5 = foo2(1, i); // any var r6 = foo2('', i2); // string @@ -50,5 +50,5 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun var r8 = foo3(1, i2, 1); // error ~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. var r9 = foo3('', i2, ''); // string \ No newline at end of file diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt index 149a20e92a5..bcfa8d8fbf9 100644 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,19): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,19): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,20): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,19): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts (4 errors) ==== @@ -68,20 +68,20 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu var r10 = c.foo2(1, (x: T) => ''); // error ~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. var r10 = c.foo2(1, (x) => ''); // string var r11 = c3.foo3(1, (x: T) => '', ''); // error ~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. var r11b = c3.foo3(1, (x: T) => '', 1); // error ~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'T'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'T'. var r12 = c3.foo3(1, function (a) { return '' }, 1); // error ~~~~~~~ !!! error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate 'string'. } } \ No newline at end of file diff --git a/tests/baselines/reference/genericFunctions1.types b/tests/baselines/reference/genericFunctions1.types index d055fa3e13e..cd649a2177d 100644 --- a/tests/baselines/reference/genericFunctions1.types +++ b/tests/baselines/reference/genericFunctions1.types @@ -8,7 +8,7 @@ function foo (x: T) { return x; } var x = foo(5); // 'x' should be number >x : number ->foo(5) : number +>foo(5) : 5 >foo : (x: T) => T >5 : 5 diff --git a/tests/baselines/reference/genericRestArgs.errors.txt b/tests/baselines/reference/genericRestArgs.errors.txt index 1dc8bd6f977..2297277fe8d 100644 --- a/tests/baselines/reference/genericRestArgs.errors.txt +++ b/tests/baselines/reference/genericRestArgs.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/genericRestArgs.ts(2,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/compiler/genericRestArgs.ts(10,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '1' is not assignable to parameter of type 'any[]'. @@ -11,7 +11,7 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type ' var a1Ga = makeArrayG(1, ""); // no error ~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. var a1Gb = makeArrayG(1, ""); var a1Gc = makeArrayG(1, ""); var a1Gd = makeArrayG(1, ""); // error @@ -24,7 +24,7 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type ' var a2Ga = makeArrayGOpt(1, ""); ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate '1' is not a valid type argument because it is not a supertype of candidate '""'. var a2Gb = makeArrayG(1, ""); var a2Gc = makeArrayG(1, ""); // error ~ diff --git a/tests/baselines/reference/maxConstraints.errors.txt b/tests/baselines/reference/maxConstraints.errors.txt index 71f1a8b024f..ad8ba7f3539 100644 --- a/tests/baselines/reference/maxConstraints.errors.txt +++ b/tests/baselines/reference/maxConstraints.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'Comparable'. +tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'Comparable<1 | 2>'. ==== tests/cases/compiler/maxConstraints.ts (1 errors) ==== @@ -11,4 +11,4 @@ tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type '1' var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y }; var maxResult = max2(1, 2); ~ -!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'Comparable'. \ No newline at end of file +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'Comparable<1 | 2>'. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitReturnsInAsync1.types b/tests/baselines/reference/noImplicitReturnsInAsync1.types index e143722eb4d..19da8fdfaf4 100644 --- a/tests/baselines/reference/noImplicitReturnsInAsync1.types +++ b/tests/baselines/reference/noImplicitReturnsInAsync1.types @@ -14,8 +14,8 @@ async function test(isError: boolean = false) { } let x = await Promise.resolve("The test is passed without an error."); >x : string ->await Promise.resolve("The test is passed without an error.") : "The test is passed without an error." ->Promise.resolve("The test is passed without an error.") : Promise<"The test is passed without an error."> +>await Promise.resolve("The test is passed without an error.") : string +>Promise.resolve("The test is passed without an error.") : Promise >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index ffca8ede3d9..7944f6f43de 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -46,7 +46,7 @@ function fun(...rest: any[]): T { var a = fun(x => { x(undefined); return x; }, 10); >a : number ->fun(x => { x(undefined); return x; }, 10) : number +>fun(x => { x(undefined); return x; }, 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T >x : (p: T) => T @@ -58,7 +58,7 @@ var a = fun(x => { x(undefined); return x; }, 10); var b = fun((x => { x(undefined); return x; }), 10); >b : number ->fun((x => { x(undefined); return x; }), 10) : number +>fun((x => { x(undefined); return x; }), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T @@ -71,7 +71,7 @@ var b = fun((x => { x(undefined); return x; }), 10); var c = fun(((x => { x(undefined); return x; })), 10); >c : number ->fun(((x => { x(undefined); return x; })), 10) : number +>fun(((x => { x(undefined); return x; })), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T @@ -85,7 +85,7 @@ var c = fun(((x => { x(undefined); return x; })), 10); var d = fun((((x => { x(undefined); return x; }))), 10); >d : number ->fun((((x => { x(undefined); return x; }))), 10) : number +>fun((((x => { x(undefined); return x; }))), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(((x => { x(undefined); return x; }))) : (x: (p: T) => T) => (p: T) => T >((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T @@ -100,7 +100,7 @@ var d = fun((((x => { x(undefined); return x; }))), 10); var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); >e : number ->fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10) : number +>fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T >x : (p: T) => T @@ -118,7 +118,7 @@ var e = fun(x => { x(undefined); return x; }, x => { x(undefined var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); >f : number ->fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10) : number +>fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T @@ -138,7 +138,7 @@ var f = fun((x => { x(undefined); return x; }),(x => { x(undefin var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); >g : number ->fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10) : number +>fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T @@ -160,7 +160,7 @@ var g = fun(((x => { x(undefined); return x; })),((x => { x(unde var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); >h : number ->fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10) : number +>fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(((x => { x(undefined); return x; }))) : (x: (p: T) => T) => (p: T) => T >((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T @@ -184,7 +184,7 @@ var h = fun((((x => { x(undefined); return x; }))),((x => { x(un // Ternaries in parens var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); >i : number ->fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : number +>fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined) : (x: (p: T) => T) => any >Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined : (x: (p: T) => T) => any @@ -207,7 +207,7 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); >j : number ->fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : number +>fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any >Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any @@ -232,7 +232,7 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); >k : number ->fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : number +>fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >(Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)) : (x: (p: T) => T) => any >Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined) : (x: (p: T) => T) => any @@ -263,7 +263,7 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); >l : number ->fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : number +>fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10) : 10 >fun : { (f: FuncType, x: T): T; (f: FuncType, g: FuncType, x: T): T; } >((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))) : (x: (p: T) => T) => any >(Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined))) : (x: (p: T) => T) => any diff --git a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt index 940083ca93a..2c721724b3e 100644 --- a/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt +++ b/tests/baselines/reference/parser15.4.4.14-9-2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(16,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'string'. + Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'false'. tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error TS2304: Cannot find name 'runTestCase'. @@ -22,7 +22,7 @@ tests/cases/conformance/parser/ecmascript5/parser15.4.4.14-9-2.ts(25,1): error T var a = new Array(false,undefined,null,"0",obj,-1.3333333333333, "str",-0,true,+0, one, 1,0, false, _float, -(4/3)); ~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'boolean' is not a valid type argument because it is not a supertype of candidate 'string'. +!!! error TS2453: Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'false'. if (a.indexOf(-(4/3)) === 14 && // a[14]=_float===-(4/3) a.indexOf(0) === 7 && // a[7] = +0, 0===+0 a.indexOf(-0) === 7 && // a[7] = +0, -0===+0 diff --git a/tests/baselines/reference/taggedTemplateContextualTyping1.types b/tests/baselines/reference/taggedTemplateContextualTyping1.types index a6b2d3862ca..4e207a0d6bb 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping1.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.types @@ -48,7 +48,7 @@ function tempTag1(...rest: any[]): T { // and it is an error to invoke an any-typed value with type arguments, // so this test will error. tempTag1 `${ x => { x(undefined); return x; } }${ 10 }`; ->tempTag1 `${ x => { x(undefined); return x; } }${ 10 }` : number +>tempTag1 `${ x => { x(undefined); return x; } }${ 10 }` : 10 >tempTag1 : { (templateStrs: TemplateStringsArray, f: FuncType, x: T): T; (templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T; } >`${ x => { x(undefined); return x; } }${ 10 }` : string >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T @@ -60,7 +60,7 @@ tempTag1 `${ x => { x(undefined); return x; } }${ 10 } >10 : 10 tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; ->tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }` : number +>tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }` : 10 >tempTag1 : { (templateStrs: TemplateStringsArray, f: FuncType, x: T): T; (templateStrs: TemplateStringsArray, f: FuncType, h: FuncType, x: T): T; } >`${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }` : string >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt index b345e971ab2..2ead58862b6 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -72,7 +72,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`; ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. +!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. var a9a: {}; // Generic tag with multiple parameters of generic type passed arguments with multiple best common types diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt index 619e5081a3b..781456b8bbb 100644 --- a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInferenceES6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(63,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,79): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -71,7 +71,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`; ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. +!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. var a9a: {}; // Generic tag with multiple parameters of generic type passed arguments with multiple best common types diff --git a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types index f7fbf8200b5..897e54a2330 100644 --- a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types +++ b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types @@ -106,7 +106,7 @@ var c: C; var r2 = c.foo(1, 2); // number >r2 : number ->c.foo(1, 2) : number +>c.foo(1, 2) : 1 | 2 >c.foo : { (x: boolean, y: Date): string; (x: string, y: string): number; (x: W, y: W): W; } >c : C >foo : { (x: boolean, y: Date): string; (x: string, y: string): number; (x: W, y: W): W; } diff --git a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types index 0ab0cbee68c..bbe716d4323 100644 --- a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types +++ b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types @@ -94,7 +94,7 @@ module G { var r4 = a(1, true); >r4 : number ->a(1, true) : number +>a(1, true) : 1 >a : A >1 : 1 >true : true diff --git a/tests/baselines/reference/typeArgInference2WithError.errors.txt b/tests/baselines/reference/typeArgInference2WithError.errors.txt index 8a191ed310e..e7abedfecb7 100644 --- a/tests/baselines/reference/typeArgInference2WithError.errors.txt +++ b/tests/baselines/reference/typeArgInference2WithError.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeArgInference2WithError.ts(7,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '"abc"' is not a valid type argument because it is not a supertype of candidate '5'. ==== tests/cases/compiler/typeArgInference2WithError.ts (1 errors) ==== @@ -12,4 +12,4 @@ tests/cases/compiler/typeArgInference2WithError.ts(7,10): error TS2453: The type var z7 = foo("abc", 5); // Error ~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. \ No newline at end of file +!!! error TS2453: Type argument candidate '"abc"' is not a valid type argument because it is not a supertype of candidate '5'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInference.errors.txt b/tests/baselines/reference/typeArgumentInference.errors.txt index 51cf4ccf7d2..cc6c1d8ce96 100644 --- a/tests/baselines/reference/typeArgumentInference.errors.txt +++ b/tests/baselines/reference/typeArgumentInference.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(68,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(82,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'. Object literal may only specify known properties, and 'y' does not exist in type '{ x: number; z: Date; }'. @@ -78,7 +78,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInference.ts(84,74 var a9a = someGenerics9('', 0, []); ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. +!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. var a9a: {}; var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); var a9b: { a?: number; b?: string; }; diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index 59ed2db9b1a..ab056d461e9 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct Types of parameters 'n' and 'b' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(106,15): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(118,9): error TS2304: Cannot find name 'Window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,51): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(120,69): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. @@ -146,7 +146,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct var a9a = new someGenerics9('', 0, []); ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. +!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. var a9a: {}; var a9b = new someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); var a9b: { a?: number; b?: string; }; diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 22d18e11eca..090f8c9b852 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -15,7 +15,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst Type 'number' is not assignable to type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(66,31): error TS2345: Argument of type '(a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) => void' is not assignable to parameter of type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(73,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(85,9): error TS2304: Cannot find name 'Window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,47): error TS2304: Cannot find name 'window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(87,65): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. @@ -128,7 +128,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst var a9a = someGenerics9('', 0, []); ~~~~~~~~~~~~~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. +!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '0'. var a9a: {}; var a9b = someGenerics9<{ a?: number; b?: string; }>({ a: 0 }, { b: '' }, null); var a9b: { a?: number; b?: string; }; diff --git a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt index c1352bedb9b..e82e7e020d0 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithObjectLiteral.errors.txt @@ -1,8 +1,10 @@ +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(30,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate '0'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts(35,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate 'E2'. -==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts (1 errors) ==== +==== tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjectLiteral.ts (2 errors) ==== interface Computed { read(): T; write(value: T); @@ -33,6 +35,9 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithObjec var v1 = f1({ w: x => x, r: () => 0 }, 0); var v1 = f1({ w: x => x, r: () => 0 }, E1.X); var v1 = f1({ w: x => x, r: () => E1.X }, 0); + ~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'E1' is not a valid type argument because it is not a supertype of candidate '0'. var v2: E1; var v2 = f1({ w: x => x, r: () => E1.X }, E1.X); diff --git a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt index f275e44503a..d20b7ae4ede 100644 --- a/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt +++ b/tests/baselines/reference/typeInferenceConflictingCandidates.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeInferenceConflictingCandidates.ts(3,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. - Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. + Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '3'. ==== tests/cases/compiler/typeInferenceConflictingCandidates.ts (1 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/typeInferenceConflictingCandidates.ts(3,1): error TS2453: T g("", 3, a => a); ~ !!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'. \ No newline at end of file +!!! error TS2453: Type argument candidate '""' is not a valid type argument because it is not a supertype of candidate '3'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types index cce73bcf0a5..885b655b749 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types @@ -16,14 +16,14 @@ function foo(x: T, y: U): U { return y; } var r = foo(1, 2); >r : number ->foo(1, 2) : number +>foo(1, 2) : 2 >foo : (x: T, y: U) => U >1 : 1 >2 : 2 var r = foo({}, 1); >r : number ->foo({}, 1) : number +>foo({}, 1) : 1 >foo : (x: T, y: U) => U >{} : {} >1 : 1 @@ -82,7 +82,7 @@ function foo2(x: T, y: U) { return y; } >y : U foo2(1, ''); ->foo2(1, '') : string +>foo2(1, '') : "" >foo2 : (x: T, y: U) => U >1 : 1 >'' : "" diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types index 12aee1a7408..8e5f04507bb 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types @@ -45,7 +45,7 @@ function foo(x: T, y: U, z: V): V { return z; } //function foo(x: T, y: U, z: V): V { return z; } foo(1, 2, 3); ->foo(1, 2, 3) : number +>foo(1, 2, 3) : 3 >foo : (x: T, y: U, z: V) => V >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types index 45e92008665..80e800cb1e0 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types @@ -45,7 +45,7 @@ function foo(x: T, y: U, z: V): V { return z; } //function foo(x: T, y: U, z: V): V { return z; } foo(1, 2, ''); ->foo(1, 2, '') : string +>foo(1, 2, '') : "" >foo : (x: T, y: U, z: V) => V >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/undefinedInferentialTyping.types b/tests/baselines/reference/undefinedInferentialTyping.types index 3633c30f755..49ebbb53716 100644 --- a/tests/baselines/reference/undefinedInferentialTyping.types +++ b/tests/baselines/reference/undefinedInferentialTyping.types @@ -14,7 +14,7 @@ function f(arr: T[], elemnt: T): T { var a = f([], 3); // should be number >a : number ->f([], 3) : number +>f([], 3) : 3 >f : (arr: T[], elemnt: T) => T >[] : undefined[] >3 : 3 diff --git a/tests/baselines/reference/unionTypeInference.errors.txt b/tests/baselines/reference/unionTypeInference.errors.txt new file mode 100644 index 00000000000..a906c3a8854 --- /dev/null +++ b/tests/baselines/reference/unionTypeInference.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts(9,15): error TS2345: Argument of type '2' is not assignable to parameter of type 'string | 1'. +tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts(13,15): error TS2345: Argument of type 'number | "hello"' is not assignable to parameter of type 'string | 1'. + Type 'number' is not assignable to type 'string | 1'. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/unionTypeInference.ts (2 errors) ==== + // 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; + } + + var a1: number; + var a1 = f(1, 2); + ~ +!!! error TS2345: Argument of type '2' is not assignable to parameter of type 'string | 1'. + var a2: number; + var a2 = f(1, "hello"); + var a3: number; + var a3 = f(1, a1 || "hello"); + ~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'number | "hello"' is not assignable to parameter of type 'string | 1'. +!!! error TS2345: Type 'number' is not assignable to type 'string | 1'. + var a4: any; + var a4 = f(undefined, "abc"); + + function g(value: [string, T]): T { + return value[1]; + } + + var b1: boolean; + var b1 = g(["string", true]); + + function h(x: string|boolean|T): T { + return typeof x === "string" || typeof x === "boolean" ? undefined : x; + } + + var c1: number; + var c1 = h(5); + var c2: string; + var c2 = h("abc"); + \ No newline at end of file diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints3.types b/tests/baselines/reference/wrappedAndRecursiveConstraints3.types index 92a58f5f39f..2c4b5727abe 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints3.types +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints3.types @@ -56,7 +56,7 @@ var r = c.foo({ length: 3, charAt: (x: number) => { '' } }); var r2 = r(''); >r2 : string ->r('') : string +>r('') : "" >r : void; }>(x: V) => V >'' : ""