Skip to content

Commit 2da62a7

Browse files
authoredOct 13, 2022
fix(51112): omit parameter names that precede the type (#51142)
1 parent cf1b6b7 commit 2da62a7

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed
 

‎src/compiler/checker.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -40136,7 +40136,7 @@ namespace ts {
4013640136
}
4013740137
}
4013840138
else {
40139-
forEach(jsdocParameters, ({ name }, index) => {
40139+
forEach(jsdocParameters, ({ name, isNameFirst }, index) => {
4014040140
if (excludedParameters.has(index) || isIdentifier(name) && parameters.has(name.escapedText)) {
4014140141
return;
4014240142
}
@@ -40146,7 +40146,9 @@ namespace ts {
4014640146
}
4014740147
}
4014840148
else {
40149-
errorOrSuggestion(isJs, name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, idText(name));
40149+
if (!isNameFirst) {
40150+
errorOrSuggestion(isJs, name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, idText(name));
40151+
}
4015040152
}
4015140153
});
4015240154
}

‎tests/baselines/reference/jsdocParamTag2.errors.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
tests/cases/conformance/jsdoc/0.js(56,20): error TS8024: JSDoc '@param' tag has name 'obj', but there is no parameter with that name.
21
tests/cases/conformance/jsdoc/0.js(61,19): error TS2339: Property 'a' does not exist on type 'String'.
32
tests/cases/conformance/jsdoc/0.js(61,22): error TS2339: Property 'b' does not exist on type 'String'.
43
tests/cases/conformance/jsdoc/0.js(63,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name.
54

65

7-
==== tests/cases/conformance/jsdoc/0.js (4 errors) ====
6+
==== tests/cases/conformance/jsdoc/0.js (3 errors) ====
87
// Object literal syntax
98
/**
109
* @param {{a: string, b: string}} obj
@@ -61,8 +60,6 @@ tests/cases/conformance/jsdoc/0.js(63,20): error TS8024: JSDoc '@param' tag has
6160

6261
/**
6362
* @param {object} obj - this type gets ignored
64-
~~~
65-
!!! error TS8024: JSDoc '@param' tag has name 'obj', but there is no parameter with that name.
6663
* @param {string} obj.a
6764
* @param {string} obj.b - and x's type gets used for both parameters
6865
* @param {string} x

‎tests/baselines/reference/paramTagWrapping.errors.txt

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
tests/cases/conformance/jsdoc/bad.js(2,11): error TS1003: Identifier expected.
2-
tests/cases/conformance/jsdoc/bad.js(2,11): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name.
32
tests/cases/conformance/jsdoc/bad.js(5,4): error TS1003: Identifier expected.
43
tests/cases/conformance/jsdoc/bad.js(5,4): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name.
54
tests/cases/conformance/jsdoc/bad.js(6,20): error TS1003: Identifier expected.
@@ -24,13 +23,11 @@ tests/cases/conformance/jsdoc/bad.js(9,20): error TS7006: Parameter 'z' implicit
2423
good(1, 2, 3)
2524

2625

27-
==== tests/cases/conformance/jsdoc/bad.js (9 errors) ====
26+
==== tests/cases/conformance/jsdoc/bad.js (8 errors) ====
2827
/**
2928
* @param *
3029

3130
!!! error TS1003: Identifier expected.
32-
33-
!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name.
3431
* {number} x Arg x.
3532
* @param {number}
3633
* * y Arg y.

0 commit comments

Comments
 (0)