Skip to content

Commit b312d59

Browse files
Update Baselines and/or Applied Lint Fixes
1 parent 5bb7079 commit b312d59

9 files changed

+227
-18
lines changed

tests/baselines/reference/checkJsdocTypeTag5.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var k = function (x) { return x }
4444
/** @typedef {(x: 'hi' | 'bye') => 0 | 1 | 2} Argle */
4545
/** @type {Argle} */
4646
function blargle(s) {
47-
>blargle : (s: "hi" | "bye") => 0 | 1 | 2
47+
>blargle : (x: 'hi' | 'bye') => 0 | 1 | 2
4848
>s : "hi" | "bye"
4949

5050
return 0;
@@ -55,7 +55,7 @@ function blargle(s) {
5555
var zeroonetwo = blargle('hi')
5656
>zeroonetwo : 0 | 1 | 2
5757
>blargle('hi') : 0 | 1 | 2
58-
>blargle : (s: "hi" | "bye") => 0 | 1 | 2
58+
>blargle : (x: "hi" | "bye") => 0 | 1 | 2
5959
>'hi' : "hi"
6060

6161
/** @typedef {{(s: string): 0 | 1; (b: boolean): 2 | 3 }} Gioconda */

tests/baselines/reference/checkJsdocTypeTag6.errors.txt

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
tests/cases/conformance/jsdoc/test.js(1,12): error TS8030: The type of a function declaration must match the function's signature.
22
tests/cases/conformance/jsdoc/test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'.
33
tests/cases/conformance/jsdoc/test.js(10,12): error TS8030: The type of a function declaration must match the function's signature.
4+
tests/cases/conformance/jsdoc/test.js(23,12): error TS8030: The type of a function declaration must match the function's signature.
5+
tests/cases/conformance/jsdoc/test.js(27,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
6+
tests/cases/conformance/jsdoc/test.js(30,7): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
7+
tests/cases/conformance/jsdoc/test.js(34,3): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
8+
tests/cases/conformance/jsdoc/test.js(37,3): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
9+
tests/cases/conformance/jsdoc/test.js(40,3): error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
410

511

6-
==== tests/cases/conformance/jsdoc/test.js (3 errors) ====
12+
==== tests/cases/conformance/jsdoc/test.js (9 errors) ====
713
/** @type {number} */
814
~~~~~~
915
!!! error TS8030: The type of a function declaration must match the function's signature.
@@ -28,4 +34,39 @@ tests/cases/conformance/jsdoc/test.js(10,12): error TS8030: The type of a functi
2834
// TODO: Should be an error since signature doesn't match.
2935
/** @type {(a: number, b: number, c: number) => number} */
3036
function add3(a, b) { return a + b; }
37+
38+
// Confirm initializers are compatible.
39+
// They can't have more parameters than the type/context.
40+
41+
/** @type {() => void} */
42+
~~~~~~~~~~
43+
!!! error TS8030: The type of a function declaration must match the function's signature.
44+
function funcWithMoreParameters(more) {} // error
45+
46+
/** @type {() => void} */
47+
const variableWithMoreParameters = function (more) {}; // error
48+
~~~~~~~~~~~~~~~~~~~~~~~~~~
49+
!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
50+
51+
/** @type {() => void} */
52+
const arrowWithMoreParameters = (more) => {}; // error
53+
~~~~~~~~~~~~~~~~~~~~~~~
54+
!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
55+
56+
({
57+
/** @type {() => void} */
58+
methodWithMoreParameters(more) {}, // error
59+
~~~~~~~~~~~~~~~~~~~~~~~~
60+
!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
61+
62+
/** @type {() => void} */
63+
propWithMoreParameters: function (more) {}, // error
64+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65+
!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
66+
67+
/** @type {() => void} */
68+
arrowWithMoreParameters: (more) => {}, // error
69+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70+
!!! error TS2322: Type '(more: any) => void' is not assignable to type '() => void'.
71+
});
3172

tests/baselines/reference/checkJsdocTypeTag6.symbols

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,39 @@ function add3(a, b) { return a + b; }
3737
>a : Symbol(a, Decl(test.js, 17, 14))
3838
>b : Symbol(b, Decl(test.js, 17, 16))
3939

40+
// Confirm initializers are compatible.
41+
// They can't have more parameters than the type/context.
42+
43+
/** @type {() => void} */
44+
function funcWithMoreParameters(more) {} // error
45+
>funcWithMoreParameters : Symbol(funcWithMoreParameters, Decl(test.js, 17, 37))
46+
>more : Symbol(more, Decl(test.js, 23, 32))
47+
48+
/** @type {() => void} */
49+
const variableWithMoreParameters = function (more) {}; // error
50+
>variableWithMoreParameters : Symbol(variableWithMoreParameters, Decl(test.js, 26, 5))
51+
>more : Symbol(more, Decl(test.js, 26, 45))
52+
53+
/** @type {() => void} */
54+
const arrowWithMoreParameters = (more) => {}; // error
55+
>arrowWithMoreParameters : Symbol(arrowWithMoreParameters, Decl(test.js, 29, 5))
56+
>more : Symbol(more, Decl(test.js, 29, 33))
57+
58+
({
59+
/** @type {() => void} */
60+
methodWithMoreParameters(more) {}, // error
61+
>methodWithMoreParameters : Symbol(methodWithMoreParameters, Decl(test.js, 31, 2))
62+
>more : Symbol(more, Decl(test.js, 33, 27))
63+
64+
/** @type {() => void} */
65+
propWithMoreParameters: function (more) {}, // error
66+
>propWithMoreParameters : Symbol(propWithMoreParameters, Decl(test.js, 33, 36))
67+
>more : Symbol(more, Decl(test.js, 36, 36))
68+
69+
/** @type {() => void} */
70+
arrowWithMoreParameters: (more) => {}, // error
71+
>arrowWithMoreParameters : Symbol(arrowWithMoreParameters, Decl(test.js, 36, 45))
72+
>more : Symbol(more, Decl(test.js, 39, 28))
73+
74+
});
75+

tests/baselines/reference/checkJsdocTypeTag6.types

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var g = function (prop) {
1616

1717
/** @type {(a: number) => number} */
1818
function add1(a, b) { return a + b; }
19-
>add1 : (a: number, b: any) => number
19+
>add1 : (a: number) => number
2020
>a : number
2121
>b : any
2222
>a + b : any
@@ -35,10 +35,53 @@ function add2(a, b) { return a + b; }
3535
// TODO: Should be an error since signature doesn't match.
3636
/** @type {(a: number, b: number, c: number) => number} */
3737
function add3(a, b) { return a + b; }
38-
>add3 : (a: number, b: number) => number
38+
>add3 : (a: number, b: number, c: number) => number
3939
>a : number
4040
>b : number
4141
>a + b : number
4242
>a : number
4343
>b : number
4444

45+
// Confirm initializers are compatible.
46+
// They can't have more parameters than the type/context.
47+
48+
/** @type {() => void} */
49+
function funcWithMoreParameters(more) {} // error
50+
>funcWithMoreParameters : () => void
51+
>more : any
52+
53+
/** @type {() => void} */
54+
const variableWithMoreParameters = function (more) {}; // error
55+
>variableWithMoreParameters : () => void
56+
>function (more) {} : (more: any) => void
57+
>more : any
58+
59+
/** @type {() => void} */
60+
const arrowWithMoreParameters = (more) => {}; // error
61+
>arrowWithMoreParameters : () => void
62+
>(more) => {} : (more: any) => void
63+
>more : any
64+
65+
({
66+
>({ /** @type {() => void} */ methodWithMoreParameters(more) {}, // error /** @type {() => void} */ propWithMoreParameters: function (more) {}, // error /** @type {() => void} */ arrowWithMoreParameters: (more) => {}, // error}) : { methodWithMoreParameters(): void; propWithMoreParameters: () => void; arrowWithMoreParameters: () => void; }
67+
>{ /** @type {() => void} */ methodWithMoreParameters(more) {}, // error /** @type {() => void} */ propWithMoreParameters: function (more) {}, // error /** @type {() => void} */ arrowWithMoreParameters: (more) => {}, // error} : { methodWithMoreParameters(): void; propWithMoreParameters: () => void; arrowWithMoreParameters: () => void; }
68+
69+
/** @type {() => void} */
70+
methodWithMoreParameters(more) {}, // error
71+
>methodWithMoreParameters : (more: any) => void
72+
>more : any
73+
74+
/** @type {() => void} */
75+
propWithMoreParameters: function (more) {}, // error
76+
>propWithMoreParameters : () => void
77+
>function (more) {} : (more: any) => void
78+
>more : any
79+
80+
/** @type {() => void} */
81+
arrowWithMoreParameters: (more) => {}, // error
82+
>arrowWithMoreParameters : () => void
83+
>(more) => {} : (more: any) => void
84+
>more : any
85+
86+
});
87+

tests/baselines/reference/checkJsdocTypeTag7.symbols

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,17 @@ class C {
1111
>foo : Symbol(C.foo, Decl(test.js, 4, 9))
1212
>a : Symbol(a, Decl(test.js, 6, 8))
1313
>b : Symbol(b, Decl(test.js, 6, 10))
14+
15+
/** @type {(optional?) => void} */
16+
methodWithOptionalParameters() {}
17+
>methodWithOptionalParameters : Symbol(C.methodWithOptionalParameters, Decl(test.js, 6, 16))
18+
19+
/** @type {(optional?) => void} */
20+
propWithOptionalParameters = function () {};
21+
>propWithOptionalParameters : Symbol(C.propWithOptionalParameters, Decl(test.js, 9, 37))
22+
23+
/** @type {(optional?) => void} */
24+
arrowWithOptionalParameters = () => {};
25+
>arrowWithOptionalParameters : Symbol(C.arrowWithOptionalParameters, Decl(test.js, 12, 48))
1426
}
1527

tests/baselines/reference/checkJsdocTypeTag7.types

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,19 @@ class C {
1111
>foo : (a: string, b: number) => void
1212
>a : string
1313
>b : number
14+
15+
/** @type {(optional?) => void} */
16+
methodWithOptionalParameters() {}
17+
>methodWithOptionalParameters : (optional?: any) => void
18+
19+
/** @type {(optional?) => void} */
20+
propWithOptionalParameters = function () {};
21+
>propWithOptionalParameters : (optional?: any) => void
22+
>function () {} : () => void
23+
24+
/** @type {(optional?) => void} */
25+
arrowWithOptionalParameters = () => {};
26+
>arrowWithOptionalParameters : (optional?: any) => void
27+
>() => {} : () => void
1428
}
1529

tests/baselines/reference/jsDocDontBreakWithNamespaces.baseline

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,82 @@
181181
"kind": "space"
182182
}
183183
],
184-
"parameters": [],
185-
"documentation": [],
186-
"tags": [
184+
"parameters": [
187185
{
188-
"name": "type",
189-
"text": [
186+
"name": "arg0",
187+
"documentation": [],
188+
"displayParts": [
190189
{
191-
"text": "{function(module:xxxx, module:xxxx): module:xxxxx}",
192-
"kind": "text"
190+
"text": "arg0",
191+
"kind": "parameterName"
192+
},
193+
{
194+
"text": ":",
195+
"kind": "punctuation"
196+
},
197+
{
198+
"text": " ",
199+
"kind": "space"
200+
},
201+
{
202+
"text": "any",
203+
"kind": "keyword"
193204
}
194-
]
205+
],
206+
"isOptional": false,
207+
"isRest": false
208+
},
209+
{
210+
"name": "arg1",
211+
"documentation": [],
212+
"displayParts": [
213+
{
214+
"text": "arg1",
215+
"kind": "parameterName"
216+
},
217+
{
218+
"text": ":",
219+
"kind": "punctuation"
220+
},
221+
{
222+
"text": " ",
223+
"kind": "space"
224+
},
225+
{
226+
"text": "any",
227+
"kind": "keyword"
228+
}
229+
],
230+
"isOptional": false,
231+
"isRest": false
232+
},
233+
{
234+
"name": "arg2",
235+
"documentation": [],
236+
"displayParts": [
237+
{
238+
"text": "arg2",
239+
"kind": "parameterName"
240+
},
241+
{
242+
"text": ":",
243+
"kind": "punctuation"
244+
},
245+
{
246+
"text": " ",
247+
"kind": "space"
248+
},
249+
{
250+
"text": "any",
251+
"kind": "keyword"
252+
}
253+
],
254+
"isOptional": false,
255+
"isRest": false
195256
}
196-
]
257+
],
258+
"documentation": [],
259+
"tags": []
197260
}
198261
],
199262
"applicableSpan": {

tests/baselines/reference/jsdocTypeTagRequiredParameters.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ tests/cases/conformance/jsdoc/a.js(13,1): error TS2554: Expected 1 arguments, bu
2121
g() // should error
2222
~~~
2323
!!! error TS2554: Expected 1 arguments, but got 0.
24-
!!! related TS6210 tests/cases/conformance/jsdoc/a.js:5:12: An argument for 's' was not provided.
24+
!!! related TS6210 tests/cases/conformance/jsdoc/a.js:4:13: An argument for 's' was not provided.
2525
h()
2626
~~~
2727
!!! error TS2554: Expected 1 arguments, but got 0.
28-
!!! related TS6210 tests/cases/conformance/jsdoc/a.js:8:12: An argument for 's' was not provided.
28+
!!! related TS6210 tests/cases/conformance/jsdoc/a.js:7:14: An argument for 's' was not provided.
2929

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== tests/cases/conformance/jsdoc/bug25618.js ===
22
/** @type {<T>(param?: T) => T | undefined} */
33
function typed(param) {
4-
>typed : <T>(param: T | undefined) => T | undefined
4+
>typed : <T>(param?: T | undefined) => T | undefined
55
>param : T | undefined
66

77
return param;
@@ -11,7 +11,7 @@ function typed(param) {
1111
var n = typed(1);
1212
>n : number | undefined
1313
>typed(1) : 1 | undefined
14-
>typed : <T>(param: T | undefined) => T | undefined
14+
>typed : <T>(param?: T | undefined) => T | undefined
1515
>1 : 1
1616

1717

0 commit comments

Comments
 (0)