Skip to content

Commit a5c44a3

Browse files
committed
Baseline-accept
1 parent bc9b53a commit a5c44a3

File tree

125 files changed

+5405
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+5405
-15
lines changed

tests/baselines/reference/APISample_linter.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,28 @@ function delint(sourceFile) {
7575
delintNode(sourceFile);
7676
function delintNode(node) {
7777
switch (node.kind) {
78-
case 189 /* ForStatement */:
79-
case 190 /* ForInStatement */:
80-
case 188 /* WhileStatement */:
81-
case 187 /* DoStatement */:
82-
if (node.statement.kind !== 182 /* Block */) {
78+
case 191 /* ForStatement */:
79+
case 192 /* ForInStatement */:
80+
case 190 /* WhileStatement */:
81+
case 189 /* DoStatement */:
82+
if (node.statement.kind !== 184 /* Block */) {
8383
report(node, "A looping statement's contents should be wrapped in a block body.");
8484
}
8585
break;
86-
case 186 /* IfStatement */:
86+
case 188 /* IfStatement */:
8787
var ifStatement = node;
88-
if (ifStatement.thenStatement.kind !== 182 /* Block */) {
88+
if (ifStatement.thenStatement.kind !== 184 /* Block */) {
8989
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
9090
}
9191
if (ifStatement.elseStatement &&
92-
ifStatement.elseStatement.kind !== 182 /* Block */ &&
93-
ifStatement.elseStatement.kind !== 186 /* IfStatement */) {
92+
ifStatement.elseStatement.kind !== 184 /* Block */ &&
93+
ifStatement.elseStatement.kind !== 188 /* IfStatement */) {
9494
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
9595
}
9696
break;
97-
case 172 /* BinaryExpression */:
97+
case 173 /* BinaryExpression */:
9898
var op = node.operatorToken.kind;
99-
if (op === 28 /* EqualsEqualsToken */ || op == 29 /* ExclamationEqualsToken */) {
99+
if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) {
100100
report(node, "Use '===' and '!=='.");
101101
}
102102
break;
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [asOperator1.ts]
2+
var as = 43;
3+
var x = undefined as number;
4+
var y = (null as string).length;
5+
var z = Date as any as string;
6+
7+
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
8+
var j = 32 as number|string;
9+
j = '';
10+
11+
12+
//// [asOperator1.js]
13+
var as = 43;
14+
var x = undefined;
15+
var y = null.length;
16+
var z = Date;
17+
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
18+
var j = 32;
19+
j = '';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/conformance/expressions/asOperator/asOperator1.ts ===
2+
var as = 43;
3+
>as : Symbol(as, Decl(asOperator1.ts, 0, 3))
4+
5+
var x = undefined as number;
6+
>x : Symbol(x, Decl(asOperator1.ts, 1, 3))
7+
>undefined : Symbol(undefined)
8+
9+
var y = (null as string).length;
10+
>y : Symbol(y, Decl(asOperator1.ts, 2, 3))
11+
>(null as string).length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
12+
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
13+
14+
var z = Date as any as string;
15+
>z : Symbol(z, Decl(asOperator1.ts, 3, 3))
16+
>Date : Symbol(Date, Decl(lib.d.ts, 633, 23), Decl(lib.d.ts, 815, 11))
17+
18+
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
19+
var j = 32 as number|string;
20+
>j : Symbol(j, Decl(asOperator1.ts, 6, 3))
21+
22+
j = '';
23+
>j : Symbol(j, Decl(asOperator1.ts, 6, 3))
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
=== tests/cases/conformance/expressions/asOperator/asOperator1.ts ===
2+
var as = 43;
3+
>as : number
4+
>43 : number
5+
6+
var x = undefined as number;
7+
>x : number
8+
>undefined as number : number
9+
>undefined : undefined
10+
11+
var y = (null as string).length;
12+
>y : number
13+
>(null as string).length : number
14+
>(null as string) : string
15+
>null as string : string
16+
>null : null
17+
>length : number
18+
19+
var z = Date as any as string;
20+
>z : string
21+
>Date as any as string : string
22+
>Date as any : any
23+
>Date : DateConstructor
24+
25+
// Should parse as a union type, not a bitwise 'or' of (32 as number) and 'string'
26+
var j = 32 as number|string;
27+
>j : string | number
28+
>32 as number|string : string | number
29+
>32 : number
30+
31+
j = '';
32+
>j = '' : string
33+
>j : string | number
34+
>'' : string
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests/cases/conformance/expressions/asOperator/asOperator2.ts(1,9): error TS2352: Neither type 'number' nor type 'string' is assignable to the other.
2+
3+
4+
==== tests/cases/conformance/expressions/asOperator/asOperator2.ts (1 errors) ====
5+
var x = 23 as string;
6+
~~~~~~~~~~~~
7+
!!! error TS2352: Neither type 'number' nor type 'string' is assignable to the other.
8+
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [asOperator2.ts]
2+
var x = 23 as string;
3+
4+
5+
//// [asOperator2.js]
6+
var x = 23;
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//// [asOperator3.ts]
2+
declare function tag(...x: any[]): any;
3+
4+
var a = `${123 + 456 as number}`;
5+
var b = `leading ${123 + 456 as number}`;
6+
var c = `${123 + 456 as number} trailing`;
7+
var d = `Hello ${123} World` as string;
8+
var e = `Hello` as string;
9+
var f = 1 + `${1} end of string` as string;
10+
var g = tag `Hello ${123} World` as string;
11+
var h = tag `Hello` as string;
12+
13+
//// [asOperator3.js]
14+
var a = "" + 123 + 456;
15+
var b = "leading " + 123 + 456;
16+
var c = 123 + 456 + " trailing";
17+
var d = ("Hello " + 123 + " World");
18+
var e = "Hello";
19+
var f = 1 + (1 + " end of string");
20+
var g = (_a = ["Hello ", " World"], _a.raw = ["Hello ", " World"], tag(_a, 123));
21+
var h = (_b = ["Hello"], _b.raw = ["Hello"], tag(_b));
22+
var _a, _b;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
=== tests/cases/conformance/expressions/asOperator/asOperator3.ts ===
2+
declare function tag(...x: any[]): any;
3+
>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0))
4+
>x : Symbol(x, Decl(asOperator3.ts, 0, 21))
5+
6+
var a = `${123 + 456 as number}`;
7+
>a : Symbol(a, Decl(asOperator3.ts, 2, 3))
8+
9+
var b = `leading ${123 + 456 as number}`;
10+
>b : Symbol(b, Decl(asOperator3.ts, 3, 3))
11+
12+
var c = `${123 + 456 as number} trailing`;
13+
>c : Symbol(c, Decl(asOperator3.ts, 4, 3))
14+
15+
var d = `Hello ${123} World` as string;
16+
>d : Symbol(d, Decl(asOperator3.ts, 5, 3))
17+
18+
var e = `Hello` as string;
19+
>e : Symbol(e, Decl(asOperator3.ts, 6, 3))
20+
21+
var f = 1 + `${1} end of string` as string;
22+
>f : Symbol(f, Decl(asOperator3.ts, 7, 3))
23+
24+
var g = tag `Hello ${123} World` as string;
25+
>g : Symbol(g, Decl(asOperator3.ts, 8, 3))
26+
>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0))
27+
28+
var h = tag `Hello` as string;
29+
>h : Symbol(h, Decl(asOperator3.ts, 9, 3))
30+
>tag : Symbol(tag, Decl(asOperator3.ts, 0, 0))
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
=== tests/cases/conformance/expressions/asOperator/asOperator3.ts ===
2+
declare function tag(...x: any[]): any;
3+
>tag : (...x: any[]) => any
4+
>x : any[]
5+
6+
var a = `${123 + 456 as number}`;
7+
>a : string
8+
>`${123 + 456 as number}` : string
9+
>123 + 456 as number : number
10+
>123 + 456 : number
11+
>123 : number
12+
>456 : number
13+
14+
var b = `leading ${123 + 456 as number}`;
15+
>b : string
16+
>`leading ${123 + 456 as number}` : string
17+
>123 + 456 as number : number
18+
>123 + 456 : number
19+
>123 : number
20+
>456 : number
21+
22+
var c = `${123 + 456 as number} trailing`;
23+
>c : string
24+
>`${123 + 456 as number} trailing` : string
25+
>123 + 456 as number : number
26+
>123 + 456 : number
27+
>123 : number
28+
>456 : number
29+
30+
var d = `Hello ${123} World` as string;
31+
>d : string
32+
>`Hello ${123} World` as string : string
33+
>`Hello ${123} World` : string
34+
>123 : number
35+
36+
var e = `Hello` as string;
37+
>e : string
38+
>`Hello` as string : string
39+
>`Hello` : string
40+
41+
var f = 1 + `${1} end of string` as string;
42+
>f : string
43+
>1 + `${1} end of string` as string : string
44+
>1 + `${1} end of string` : string
45+
>1 : number
46+
>`${1} end of string` : string
47+
>1 : number
48+
49+
var g = tag `Hello ${123} World` as string;
50+
>g : string
51+
>tag `Hello ${123} World` as string : string
52+
>tag `Hello ${123} World` : any
53+
>tag : (...x: any[]) => any
54+
>`Hello ${123} World` : string
55+
>123 : number
56+
57+
var h = tag `Hello` as string;
58+
>h : string
59+
>tag `Hello` as string : string
60+
>tag `Hello` : any
61+
>tag : (...x: any[]) => any
62+
>`Hello` : string
63+
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//// [asOperatorASI.ts]
2+
class Foo { }
3+
declare function as(...args: any[]);
4+
5+
// Example 1
6+
var x = 10
7+
as `Hello world`; // should not error
8+
9+
// Example 2
10+
var y = 20
11+
as(Foo); // should emit
12+
13+
14+
//// [asOperatorASI.js]
15+
var Foo = (function () {
16+
function Foo() {
17+
}
18+
return Foo;
19+
})();
20+
// Example 1
21+
var x = 10;
22+
(_a = ["Hello world"], _a.raw = ["Hello world"], as(_a)); // should not error
23+
// Example 2
24+
var y = 20;
25+
as(Foo); // should emit
26+
var _a;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts ===
2+
class Foo { }
3+
>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0))
4+
5+
declare function as(...args: any[]);
6+
>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13))
7+
>args : Symbol(args, Decl(asOperatorASI.ts, 1, 20))
8+
9+
// Example 1
10+
var x = 10
11+
>x : Symbol(x, Decl(asOperatorASI.ts, 4, 3))
12+
13+
as `Hello world`; // should not error
14+
>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13))
15+
16+
// Example 2
17+
var y = 20
18+
>y : Symbol(y, Decl(asOperatorASI.ts, 8, 3))
19+
20+
as(Foo); // should emit
21+
>as : Symbol(as, Decl(asOperatorASI.ts, 0, 13))
22+
>Foo : Symbol(Foo, Decl(asOperatorASI.ts, 0, 0))
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== tests/cases/conformance/expressions/asOperator/asOperatorASI.ts ===
2+
class Foo { }
3+
>Foo : Foo
4+
5+
declare function as(...args: any[]);
6+
>as : (...args: any[]) => any
7+
>args : any[]
8+
9+
// Example 1
10+
var x = 10
11+
>x : number
12+
>10 : number
13+
14+
as `Hello world`; // should not error
15+
>as `Hello world` : any
16+
>as : (...args: any[]) => any
17+
>`Hello world` : string
18+
19+
// Example 2
20+
var y = 20
21+
>y : number
22+
>20 : number
23+
24+
as(Foo); // should emit
25+
>as(Foo) : any
26+
>as : (...args: any[]) => any
27+
>Foo : typeof Foo
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts(7,14): error TS2339: Property 'm' does not exist on type 'A<B>'.
2+
3+
4+
==== tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts (1 errors) ====
5+
interface A<T> { x: T; }
6+
interface B { m: string; }
7+
8+
// Make sure this is a type assertion to an array type, and not nested comparison operators.
9+
var x: any;
10+
var y = x as A<B>[];
11+
var z = y[0].m; // z should be string
12+
~
13+
!!! error TS2339: Property 'm' does not exist on type 'A<B>'.
14+
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//// [asOperatorAmbiguity.ts]
2+
interface A<T> { x: T; }
3+
interface B { m: string; }
4+
5+
// Make sure this is a type assertion to an array type, and not nested comparison operators.
6+
var x: any;
7+
var y = x as A<B>[];
8+
var z = y[0].m; // z should be string
9+
10+
11+
12+
//// [asOperatorAmbiguity.js]
13+
// Make sure this is a type assertion to an array type, and not nested comparison operators.
14+
var x;
15+
var y = x;
16+
var z = y[0].m; // z should be string
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts(2,9): error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other.
2+
Type 'number' is not assignable to type 'string'.
3+
4+
5+
==== tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts (1 errors) ====
6+
// should error
7+
var x = (v => v) as (x: number) => string;
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
!!! error TS2352: Neither type '(v: number) => number' nor type '(x: number) => string' is assignable to the other.
10+
!!! error TS2352: Type 'number' is not assignable to type 'string'.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//// [asOperatorContextualType.ts]
2+
// should error
3+
var x = (v => v) as (x: number) => string;
4+
5+
//// [asOperatorContextualType.js]
6+
// should error
7+
var x = (function (v) { return v; });

0 commit comments

Comments
 (0)