Skip to content

Commit e5708e1

Browse files
authored
Merge pull request #29352 from Microsoft/qualified-name-param-tag-error
Qualified name param tag error
2 parents fadd95f + ed57758 commit e5708e1

18 files changed

+217
-3
lines changed

src/compiler/checker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24785,9 +24785,17 @@ namespace ts {
2478524785
return;
2478624786
}
2478724787
if (!containsArgumentsReference(decl)) {
24788-
error(node.name,
24789-
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name,
24790-
idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name));
24788+
if (isQualifiedName(node.name)) {
24789+
error(node.name,
24790+
Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1,
24791+
entityNameToString(node.name),
24792+
entityNameToString(node.name.left));
24793+
}
24794+
else {
24795+
error(node.name,
24796+
Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name,
24797+
idText(node.name));
24798+
}
2479124799
}
2479224800
else if (findLast(getJSDocTags(decl), isJSDocParameterTag) === node &&
2479324801
node.typeExpression && node.typeExpression.type &&

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4266,6 +4266,10 @@
42664266
"category": "Error",
42674267
"code": 8031
42684268
},
4269+
"Qualified name '{0}' is not allowed without a leading '@param {object} {1}'.": {
4270+
"category": "Error",
4271+
"code": 8032
4272+
},
42694273
"Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": {
42704274
"category": "Error",
42714275
"code": 9002
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js(2,20): error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'.
2+
3+
4+
==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js (1 errors) ====
5+
/**
6+
* @param {number} xyz.p
7+
~~~~~
8+
!!! error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'.
9+
*/
10+
function g(xyz) {
11+
return xyz.p;
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js ===
2+
/**
3+
* @param {number} xyz.p
4+
*/
5+
function g(xyz) {
6+
>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject.js, 0, 0))
7+
>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11))
8+
9+
return xyz.p;
10+
>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11))
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js ===
2+
/**
3+
* @param {number} xyz.p
4+
*/
5+
function g(xyz) {
6+
>g : (xyz: any) => any
7+
>xyz : any
8+
9+
return xyz.p;
10+
>xyz.p : any
11+
>xyz : any
12+
>p : any
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js(2,20): error TS8032: Qualified name 'xyz.bar' is not allowed without a leading '@param {object} xyz'.
2+
3+
4+
==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js (1 errors) ====
5+
/**
6+
* @param {object} xyz.bar
7+
~~~~~~~
8+
!!! error TS8032: Qualified name 'xyz.bar' is not allowed without a leading '@param {object} xyz'.
9+
* @param {number} xyz.bar.p
10+
*/
11+
function g(xyz) {
12+
return xyz.bar.p;
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js ===
2+
/**
3+
* @param {object} xyz.bar
4+
* @param {number} xyz.bar.p
5+
*/
6+
function g(xyz) {
7+
>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject2.js, 0, 0))
8+
>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject2.js, 4, 11))
9+
10+
return xyz.bar.p;
11+
>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject2.js, 4, 11))
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js ===
2+
/**
3+
* @param {object} xyz.bar
4+
* @param {number} xyz.bar.p
5+
*/
6+
function g(xyz) {
7+
>g : (xyz: any) => any
8+
>xyz : any
9+
10+
return xyz.bar.p;
11+
>xyz.bar.p : any
12+
>xyz.bar : any
13+
>xyz : any
14+
>bar : any
15+
>p : any
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'.
2+
3+
4+
==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js (1 errors) ====
5+
/**
6+
* @param {object} xyz
7+
* @param {number} xyz.bar.p
8+
~~~~~~~~~
9+
!!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'.
10+
*/
11+
function g(xyz) {
12+
return xyz.bar.p;
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js ===
2+
/**
3+
* @param {object} xyz
4+
* @param {number} xyz.bar.p
5+
*/
6+
function g(xyz) {
7+
>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject3.js, 0, 0))
8+
>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject3.js, 4, 11))
9+
10+
return xyz.bar.p;
11+
>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject3.js, 4, 11))
12+
}

0 commit comments

Comments
 (0)