Skip to content

Commit b8e3c41

Browse files
KingwlRyanCavanaugh
authored andcommitted
fix jsdoc iterator on expression of export assignment (#30558)
1 parent 867c992 commit b8e3c41

File tree

7 files changed

+101
-0
lines changed

7 files changed

+101
-0
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,7 @@ namespace ts {
22212221
function getNextJSDocCommentLocation(node: Node) {
22222222
const parent = node.parent;
22232223
if (parent.kind === SyntaxKind.PropertyAssignment ||
2224+
parent.kind === SyntaxKind.ExportAssignment ||
22242225
parent.kind === SyntaxKind.PropertyDeclaration ||
22252226
parent.kind === SyntaxKind.ExpressionStatement && node.kind === SyntaxKind.PropertyAccessExpression ||
22262227
getNestedModuleDeclaration(parent) ||
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/compiler/a.js ===
2+
/**
3+
No type information for this code. * A number, or a string containing a number.
4+
No type information for this code. * @typedef {(number|string)} NumberLike
5+
No type information for this code. */
6+
No type information for this code.
7+
No type information for this code./** @type {NumberLike[]} */export default ([ ]);
8+
No type information for this code.
9+
No type information for this code.=== tests/cases/compiler/b.ts ===
10+
import A from './a'
11+
>A : Symbol(A, Decl(b.ts, 0, 6))
12+
13+
A[0]
14+
>A : Symbol(A, Decl(b.ts, 0, 6))
15+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/a.js ===
2+
/**
3+
* A number, or a string containing a number.
4+
* @typedef {(number|string)} NumberLike
5+
*/
6+
7+
/** @type {NumberLike[]} */export default ([ ]);
8+
>([ ]) : (string | number)[]
9+
>[ ] : undefined[]
10+
11+
=== tests/cases/compiler/b.ts ===
12+
import A from './a'
13+
>A : (string | number)[]
14+
15+
A[0]
16+
>A[0] : string | number
17+
>A : (string | number)[]
18+
>0 : 0
19+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== tests/cases/compiler/a.js ===
2+
/**
3+
No type information for this code. * A number, or a string containing a number.
4+
No type information for this code. * @typedef {(number|string)} NumberLike
5+
No type information for this code. */
6+
No type information for this code.
7+
No type information for this code.export default /** @type {NumberLike[]} */([ ]);
8+
No type information for this code.
9+
No type information for this code.=== tests/cases/compiler/b.ts ===
10+
import A from './a'
11+
>A : Symbol(A, Decl(b.ts, 0, 6))
12+
13+
A[0]
14+
>A : Symbol(A, Decl(b.ts, 0, 6))
15+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/compiler/a.js ===
2+
/**
3+
* A number, or a string containing a number.
4+
* @typedef {(number|string)} NumberLike
5+
*/
6+
7+
export default /** @type {NumberLike[]} */([ ]);
8+
>([ ]) : (string | number)[]
9+
>[ ] : undefined[]
10+
11+
=== tests/cases/compiler/b.ts ===
12+
import A from './a'
13+
>A : (string | number)[]
14+
15+
A[0]
16+
>A[0] : string | number
17+
>A : (string | number)[]
18+
>0 : 0
19+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
// @allowJs: true
3+
// @checkJs: true
4+
// @noEmit: true
5+
6+
/**
7+
* A number, or a string containing a number.
8+
* @typedef {(number|string)} NumberLike
9+
*/
10+
11+
// @Filename: a.js
12+
/** @type {NumberLike[]} */export default ([ ]);
13+
14+
// @Filename: b.ts
15+
import A from './a'
16+
A[0]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
// @allowJs: true
3+
// @checkJs: true
4+
// @noEmit: true
5+
6+
/**
7+
* A number, or a string containing a number.
8+
* @typedef {(number|string)} NumberLike
9+
*/
10+
11+
// @Filename: a.js
12+
export default /** @type {NumberLike[]} */([ ]);
13+
14+
// @Filename: b.ts
15+
import A from './a'
16+
A[0]

0 commit comments

Comments
 (0)