Skip to content

Commit 4db1c13

Browse files
authored
No dupe jsdoc for assignment inside an initializer (#24973)
1 parent 57e652d commit 4db1c13

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

src/parser/utilities.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,12 @@ namespace ts {
20972097
if (isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.EqualsToken ||
20982098
isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.EqualsToken ||
20992099
node.kind === SyntaxKind.PropertyAccessExpression && node.parent && node.parent.kind === SyntaxKind.ExpressionStatement) {
2100-
getJSDocCommentsAndTagsWorker(parent);
2100+
if (isBinaryExpression(parent)) {
2101+
getJSDocCommentsAndTagsWorker(parent.parent);
2102+
}
2103+
else {
2104+
getJSDocCommentsAndTagsWorker(parent);
2105+
}
21012106
}
21022107

21032108
// Pull parameter comments from declaring function as well
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/conformance/jsdoc/a.js(2,11): error TS2304: Cannot find name 'b'.
2+
3+
4+
==== tests/cases/conformance/jsdoc/a.js (1 errors) ====
5+
/** doc */
6+
const a = b = () => 0;
7+
~
8+
!!! error TS2304: Cannot find name 'b'.
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
=== tests/cases/conformance/jsdoc/a.js ===
2+
/** doc */
3+
const a = b = () => 0;
4+
>a : Symbol(a, Decl(a.js, 1, 5))
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
=== tests/cases/conformance/jsdoc/a.js ===
2+
/** doc */
3+
const a = b = () => 0;
4+
>a : () => number
5+
>b = () => 0 : () => number
6+
>b : any
7+
>() => 0 : () => number
8+
>0 : 0
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
// @Filename: a.js
5+
/** doc */
6+
const a = b = () => 0;

0 commit comments

Comments
 (0)