Skip to content

Commit bd422e3

Browse files
author
Kanchalai Tanglertsampan
committed
Add tests and update baselines
1 parent 72e6678 commit bd422e3

File tree

11 files changed

+1485
-0
lines changed

11 files changed

+1485
-0
lines changed

tests/baselines/reference/jsDocTypeTag1.js

Lines changed: 584 additions & 0 deletions
Large diffs are not rendered by default.

tests/baselines/reference/jsDocTypeTag2.js

Lines changed: 598 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [0.js]
2+
// @ts-check
3+
/** @type {*} */
4+
var anyT = 2;
5+
6+
/** @type {?} */
7+
var anyT1 = 2;
8+
anyT1 = "hi";
9+
10+
/** @type {Function} */
11+
const x = (a) => a + 1;
12+
x(1);
13+
14+
/** @type {function (number)} */
15+
const x1 = (a) => a + 1;
16+
x1(0);
17+
18+
/** @type {function (number): number} */
19+
const x2 = (a) => a + 1;
20+
x2(0);
21+
22+
//// [0.js]
23+
// @ts-check
24+
/** @type {*} */
25+
var anyT = 2;
26+
/** @type {?} */
27+
var anyT1 = 2;
28+
anyT1 = "hi";
29+
/** @type {Function} */
30+
var x = function (a) { return a + 1; };
31+
x(1);
32+
/** @type {function (number)} */
33+
var x1 = function (a) { return a + 1; };
34+
x1(0);
35+
/** @type {function (number): number} */
36+
var x2 = function (a) { return a + 1; };
37+
x2(0);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
=== tests/cases/conformance/salsa/0.js ===
2+
// @ts-check
3+
/** @type {*} */
4+
var anyT = 2;
5+
>anyT : Symbol(anyT, Decl(0.js, 2, 3))
6+
7+
/** @type {?} */
8+
var anyT1 = 2;
9+
>anyT1 : Symbol(anyT1, Decl(0.js, 5, 3))
10+
11+
anyT1 = "hi";
12+
>anyT1 : Symbol(anyT1, Decl(0.js, 5, 3))
13+
14+
/** @type {Function} */
15+
const x = (a) => a + 1;
16+
>x : Symbol(x, Decl(0.js, 9, 5))
17+
>a : Symbol(a, Decl(0.js, 9, 11))
18+
>a : Symbol(a, Decl(0.js, 9, 11))
19+
20+
x(1);
21+
>x : Symbol(x, Decl(0.js, 9, 5))
22+
23+
/** @type {function (number)} */
24+
const x1 = (a) => a + 1;
25+
>x1 : Symbol(x1, Decl(0.js, 13, 5))
26+
>a : Symbol(a, Decl(0.js, 13, 12))
27+
>a : Symbol(a, Decl(0.js, 13, 12))
28+
29+
x1(0);
30+
>x1 : Symbol(x1, Decl(0.js, 13, 5))
31+
32+
/** @type {function (number): number} */
33+
const x2 = (a) => a + 1;
34+
>x2 : Symbol(x2, Decl(0.js, 17, 5))
35+
>a : Symbol(a, Decl(0.js, 17, 12))
36+
>a : Symbol(a, Decl(0.js, 17, 12))
37+
38+
x2(0);
39+
>x2 : Symbol(x2, Decl(0.js, 17, 5))
40+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=== tests/cases/conformance/salsa/0.js ===
2+
// @ts-check
3+
/** @type {*} */
4+
var anyT = 2;
5+
>anyT : any
6+
>2 : 2
7+
8+
/** @type {?} */
9+
var anyT1 = 2;
10+
>anyT1 : any
11+
>2 : 2
12+
13+
anyT1 = "hi";
14+
>anyT1 = "hi" : "hi"
15+
>anyT1 : any
16+
>"hi" : "hi"
17+
18+
/** @type {Function} */
19+
const x = (a) => a + 1;
20+
>x : Function
21+
>(a) => a + 1 : (a: any) => any
22+
>a : any
23+
>a + 1 : any
24+
>a : any
25+
>1 : 1
26+
27+
x(1);
28+
>x(1) : any
29+
>x : Function
30+
>1 : 1
31+
32+
/** @type {function (number)} */
33+
const x1 = (a) => a + 1;
34+
>x1 : (arg0: number) => any
35+
>(a) => a + 1 : (a: any) => any
36+
>a : any
37+
>a + 1 : any
38+
>a : any
39+
>1 : 1
40+
41+
x1(0);
42+
>x1(0) : any
43+
>x1 : (arg0: number) => any
44+
>0 : 0
45+
46+
/** @type {function (number): number} */
47+
const x2 = (a) => a + 1;
48+
>x2 : (arg0: number) => number
49+
>(a) => a + 1 : (a: any) => any
50+
>a : any
51+
>a + 1 : any
52+
>a : any
53+
>1 : 1
54+
55+
x2(0);
56+
>x2(0) : number
57+
>x2 : (arg0: number) => number
58+
>0 : 0
59+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
tests/cases/conformance/salsa/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
2+
tests/cases/conformance/salsa/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'.
3+
4+
5+
==== tests/cases/conformance/salsa/0.js (2 errors) ====
6+
// @ts-check
7+
8+
/** @type {function (number)} */
9+
const x1 = (a) => a + 1;
10+
x1("string");
11+
~~~~~~~~
12+
!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
13+
14+
/** @type {function (number): number} */
15+
const x2 = (a) => a + 1;
16+
17+
/** @type {string} */
18+
var a;
19+
a = x2(0);
20+
~
21+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//// [0.js]
2+
// @ts-check
3+
4+
/** @type {function (number)} */
5+
const x1 = (a) => a + 1;
6+
x1("string");
7+
8+
/** @type {function (number): number} */
9+
const x2 = (a) => a + 1;
10+
11+
/** @type {string} */
12+
var a;
13+
a = x2(0);
14+
15+
//// [0.js]
16+
// @ts-check
17+
/** @type {function (number)} */
18+
var x1 = function (a) { return a + 1; };
19+
x1("string");
20+
/** @type {function (number): number} */
21+
var x2 = function (a) { return a + 1; };
22+
/** @type {string} */
23+
var a;
24+
a = x2(0);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// @allowJS: true
2+
// @suppressOutputPathCheck: true
3+
4+
// @filename: 0.js
5+
// @ts-check
6+
/** @type {*} */
7+
var anyT = 2;
8+
9+
/** @type {?} */
10+
var anyT1 = 2;
11+
anyT1 = "hi";
12+
13+
/** @type {Function} */
14+
const x = (a) => a + 1;
15+
x(1);
16+
17+
/** @type {function (number)} */
18+
const x1 = (a) => a + 1;
19+
x1(0);
20+
21+
/** @type {function (number): number} */
22+
const x2 = (a) => a + 1;
23+
x2(0);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @allowJS: true
2+
// @suppressOutputPathCheck: true
3+
4+
// @filename: 0.js
5+
// @ts-check
6+
7+
/** @type {function (number)} */
8+
const x1 = (a) => a + 1;
9+
x1("string");
10+
11+
/** @type {function (number): number} */
12+
const x2 = (a) => a + 1;
13+
14+
/** @type {string} */
15+
var a;
16+
a = x2(0);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/// <reference path="fourslash.ts" />
2+
// @allowJs: true
3+
// @Filename: jsDocTypeTag1.js
4+
//// /** @type {String} */
5+
//// var /*1*/S;
6+
7+
//// /** @type {Number} */
8+
//// var /*2*/N;
9+
10+
//// /** @type {Boolean} */
11+
//// var /*3*/B;
12+
13+
//// /** @type {Void} */
14+
//// var /*4*/V;
15+
16+
//// /** @type {Undefined} */
17+
//// var /*5*/U;
18+
19+
//// /** @type {Null} */
20+
//// var /*6*/Nl;
21+
22+
//// /** @type {Array} */
23+
//// var /*7*/A;
24+
25+
//// /** @type {Promise} */
26+
//// var /*8*/P;
27+
28+
//// /** @type {Object} */
29+
//// var /*9*/Obj;
30+
31+
//// /** @type {Function} */
32+
//// var /*10*/Func;
33+
34+
//// /** @type {*} */
35+
//// var /*11*/AnyType;
36+
37+
//// /** @type {?} */
38+
//// var /*12*/QType;
39+
40+
//// /** @type {String|Number} */
41+
//// var /*13*/SOrN;
42+
43+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)