11tests/cases/conformance/jsdoc/test.js(1,12): error TS8030: The type of a function declaration must match the function's signature.
22tests/cases/conformance/jsdoc/test.js(7,5): error TS2322: Type '(prop: any) => void' is not assignable to type '{ prop: string; }'.
33tests/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
0 commit comments