From 2da62a784bbba237b8239e84c8629cfafb0f595e Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Thu, 13 Oct 2022 23:37:23 +0300 Subject: [PATCH] fix(51112): omit parameter names that precede the type (#51142) --- src/compiler/checker.ts | 6 ++++-- tests/baselines/reference/jsdocParamTag2.errors.txt | 5 +---- tests/baselines/reference/paramTagWrapping.errors.txt | 5 +---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 97a0e99357567..72a6934b0413f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -40136,7 +40136,7 @@ namespace ts { } } else { - forEach(jsdocParameters, ({ name }, index) => { + forEach(jsdocParameters, ({ name, isNameFirst }, index) => { if (excludedParameters.has(index) || isIdentifier(name) && parameters.has(name.escapedText)) { return; } @@ -40146,7 +40146,9 @@ namespace ts { } } else { - errorOrSuggestion(isJs, name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, idText(name)); + if (!isNameFirst) { + errorOrSuggestion(isJs, name, Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, idText(name)); + } } }); } diff --git a/tests/baselines/reference/jsdocParamTag2.errors.txt b/tests/baselines/reference/jsdocParamTag2.errors.txt index cbf6140ee7d86..cb95ce143196b 100644 --- a/tests/baselines/reference/jsdocParamTag2.errors.txt +++ b/tests/baselines/reference/jsdocParamTag2.errors.txt @@ -1,10 +1,9 @@ -tests/cases/conformance/jsdoc/0.js(56,20): error TS8024: JSDoc '@param' tag has name 'obj', but there is no parameter with that name. tests/cases/conformance/jsdoc/0.js(61,19): error TS2339: Property 'a' does not exist on type 'String'. tests/cases/conformance/jsdoc/0.js(61,22): error TS2339: Property 'b' does not exist on type 'String'. tests/cases/conformance/jsdoc/0.js(63,20): error TS8024: JSDoc '@param' tag has name 'y', but there is no parameter with that name. -==== tests/cases/conformance/jsdoc/0.js (4 errors) ==== +==== tests/cases/conformance/jsdoc/0.js (3 errors) ==== // Object literal syntax /** * @param {{a: string, b: string}} obj @@ -61,8 +60,6 @@ tests/cases/conformance/jsdoc/0.js(63,20): error TS8024: JSDoc '@param' tag has /** * @param {object} obj - this type gets ignored - ~~~ -!!! error TS8024: JSDoc '@param' tag has name 'obj', but there is no parameter with that name. * @param {string} obj.a * @param {string} obj.b - and x's type gets used for both parameters * @param {string} x diff --git a/tests/baselines/reference/paramTagWrapping.errors.txt b/tests/baselines/reference/paramTagWrapping.errors.txt index b1564a4f85b8b..22e83a7b88beb 100644 --- a/tests/baselines/reference/paramTagWrapping.errors.txt +++ b/tests/baselines/reference/paramTagWrapping.errors.txt @@ -1,5 +1,4 @@ tests/cases/conformance/jsdoc/bad.js(2,11): error TS1003: Identifier expected. -tests/cases/conformance/jsdoc/bad.js(2,11): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. tests/cases/conformance/jsdoc/bad.js(5,4): error TS1003: Identifier expected. tests/cases/conformance/jsdoc/bad.js(5,4): error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. 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 good(1, 2, 3) -==== tests/cases/conformance/jsdoc/bad.js (9 errors) ==== +==== tests/cases/conformance/jsdoc/bad.js (8 errors) ==== /** * @param * !!! error TS1003: Identifier expected. - -!!! error TS8024: JSDoc '@param' tag has name '', but there is no parameter with that name. * {number} x Arg x. * @param {number} * * y Arg y.