Skip to content

Commit acd8c77

Browse files
committed
Accepting new baselines
1 parent eeeb05b commit acd8c77

20 files changed

+448
-2338
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(17,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
2+
tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts(26,10): error TS2349: Cannot invoke an expression whose type lacks a call signature.
3+
4+
5+
==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayOfFunctionTypes3.ts (2 errors) ====
6+
// valid uses of arrays of function types
7+
8+
var x = [() => 1, () => { }];
9+
var r2 = x[0]();
10+
11+
class C {
12+
foo: string;
13+
}
14+
var y = [C, C];
15+
var r3 = new y[0]();
16+
17+
var a: { (x: number): number; (x: string): string; };
18+
var b: { (x: number): number; (x: string): string; };
19+
var c: { (x: number): number; (x: any): any; };
20+
var z = [a, b, c];
21+
var r4 = z[0];
22+
var r5 = r4(''); // any not string
23+
~~
24+
!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.
25+
var r5b = r4(1);
26+
27+
var a2: { <T>(x: T): number; (x: string): string;};
28+
var b2: { <T>(x: T): number; (x: string): string; };
29+
var c2: { (x: number): number; <T>(x: T): any; };
30+
31+
var z2 = [a2, b2, c2];
32+
var r6 = z2[0];
33+
var r7 = r6(''); // any not string
34+
~~~~~~
35+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.

tests/baselines/reference/arrayOfFunctionTypes3.symbols

Lines changed: 0 additions & 93 deletions
This file was deleted.

tests/baselines/reference/arrayOfFunctionTypes3.types

Lines changed: 0 additions & 116 deletions
This file was deleted.

tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.symbols

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,5 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any
8282
>IWithCallSignatures : Symbol(IWithCallSignatures, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 9, 1))
8383
>IWithCallSignatures4 : Symbol(IWithCallSignatures4, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 18, 1))
8484
>a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52))
85-
>a.toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
8685
>a : Symbol(a, Decl(contextualTypeWithUnionTypeCallSignatures.ts, 35, 52))
87-
>toString : Symbol(Number.toString, Decl(lib.d.ts, 458, 18))
8886

tests/baselines/reference/contextualTypeWithUnionTypeCallSignatures.types

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ var x4: IWithCallSignatures | IWithCallSignatures4 = a => /*here a should be any
9090
>x4 : IWithCallSignatures | IWithCallSignatures4
9191
>IWithCallSignatures : IWithCallSignatures
9292
>IWithCallSignatures4 : IWithCallSignatures4
93-
>a => /*here a should be any*/ a.toString() : (a: number) => string
94-
>a : number
95-
>a.toString() : string
96-
>a.toString : (radix?: number) => string
97-
>a : number
98-
>toString : (radix?: number) => string
93+
>a => /*here a should be any*/ a.toString() : (a: any) => any
94+
>a : any
95+
>a.toString() : any
96+
>a.toString : any
97+
>a : any
98+
>toString : any
9999

tests/baselines/reference/mismatchedExplicitTypeParameterAndArgumentType.errors.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(7,30): error TS2349: Cannot invoke an expression whose type lacks a call signature.
12
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(10,30): error TS2345: Argument of type '(string | number)[]' is not assignable to parameter of type 'number[]'.
23
Type 'string | number' is not assignable to type 'number'.
34
Type 'string' is not assignable to type 'number'.
45
tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts(11,11): error TS2346: Supplied parameters do not match any signature of call target.
56

67

7-
==== tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts (2 errors) ====
8+
==== tests/cases/compiler/mismatchedExplicitTypeParameterAndArgumentType.ts (3 errors) ====
89
function map<T, U>(xs: T[], f: (x: T) => U) {
910
var ys: U[] = [];
1011
xs.forEach(x => ys.push(f(x)));
1112
return ys;
1213
}
1314

1415
var r0 = map([1, ""], (x) => x.toString());
16+
~~~~~~~~~~~~
17+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
1518
var r5 = map<any, any>([1, ""], (x) => x.toString());
1619
var r6 = map<Object, Object>([1, ""], (x) => x.toString());
1720
var r7 = map<number, string>([1, ""], (x) => x.toString()); // error
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts(93,22): error TS2349: Cannot invoke an expression whose type lacks a call signature.
2+
3+
4+
==== tests/cases/conformance/expressions/typeGuards/typeGuardsInConditionalExpression.ts (1 errors) ====
5+
// In the true expression of a conditional expression,
6+
// the type of a variable or parameter is narrowed by any type guard in the condition when true,
7+
// provided the true expression contains no assignments to the variable or parameter.
8+
// In the false expression of a conditional expression,
9+
// the type of a variable or parameter is narrowed by any type guard in the condition when false,
10+
// provided the false expression contains no assignments to the variable or parameter.
11+
12+
function foo(x: number | string) {
13+
return typeof x === "string"
14+
? x.length // string
15+
: x++; // number
16+
}
17+
function foo2(x: number | string) {
18+
// x is assigned in the if true branch, the type is not narrowed
19+
return typeof x === "string"
20+
? (x = 10 && x)// string | number
21+
: x; // string | number
22+
}
23+
function foo3(x: number | string) {
24+
// x is assigned in the if false branch, the type is not narrowed
25+
// even though assigned using same type as narrowed expression
26+
return typeof x === "string"
27+
? (x = "Hello" && x) // string | number
28+
: x; // string | number
29+
}
30+
function foo4(x: number | string) {
31+
// false branch updates the variable - so here it is not number
32+
// even though assigned using same type as narrowed expression
33+
return typeof x === "string"
34+
? x // string | number
35+
: (x = 10 && x); // string | number
36+
}
37+
function foo5(x: number | string) {
38+
// false branch updates the variable - so here it is not number
39+
return typeof x === "string"
40+
? x // string | number
41+
: (x = "hello" && x); // string | number
42+
}
43+
function foo6(x: number | string) {
44+
// Modify in both branches
45+
return typeof x === "string"
46+
? (x = 10 && x) // string | number
47+
: (x = "hello" && x); // string | number
48+
}
49+
function foo7(x: number | string | boolean) {
50+
return typeof x === "string"
51+
? x === "hello" // string
52+
: typeof x === "boolean"
53+
? x // boolean
54+
: x == 10; // number
55+
}
56+
function foo8(x: number | string | boolean) {
57+
var b: number | boolean;
58+
return typeof x === "string"
59+
? x === "hello"
60+
: ((b = x) && // number | boolean
61+
(typeof x === "boolean"
62+
? x // boolean
63+
: x == 10)); // number
64+
}
65+
function foo9(x: number | string) {
66+
var y = 10;
67+
// usage of x or assignment to separate variable shouldn't cause narrowing of type to stop
68+
return typeof x === "string"
69+
? ((y = x.length) && x === "hello") // string
70+
: x === 10; // number
71+
}
72+
function foo10(x: number | string | boolean) {
73+
// Mixing typeguards
74+
var b: boolean | number;
75+
return typeof x === "string"
76+
? x // string
77+
: ((b = x) // x is number | boolean
78+
&& typeof x === "number"
79+
&& x.toString()); // x is number
80+
}
81+
function foo11(x: number | string | boolean) {
82+
// Mixing typeguards
83+
// Assigning value to x deep inside another guard stops narrowing of type too
84+
var b: number | boolean | string;
85+
return typeof x === "string"
86+
? x // number | boolean | string - changed in the false branch
87+
: ((b = x) // x is number | boolean | string - because the assignment changed it
88+
&& typeof x === "number"
89+
&& (x = 10) // assignment to x
90+
&& x); // x is number | boolean | string
91+
}
92+
function foo12(x: number | string | boolean) {
93+
// Mixing typeguards
94+
// Assigning value to x in outer guard shouldn't stop narrowing in the inner expression
95+
var b: number | boolean | string;
96+
return typeof x === "string"
97+
? (x = 10 && x.toString().length) // number | boolean | string - changed here
98+
~~~~~~~~~~~~
99+
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
100+
: ((b = x) // x is number | boolean | string - changed in true branch
101+
&& typeof x === "number"
102+
&& x); // x is number
103+
}

0 commit comments

Comments
 (0)