Skip to content

Commit

Permalink
fix jsdoc iterator on expression of export assignment (#30558)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl authored and RyanCavanaugh committed Apr 25, 2019
1 parent 867c992 commit b8e3c41
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/utilities.ts
Expand Up @@ -2221,6 +2221,7 @@ namespace ts {
function getNextJSDocCommentLocation(node: Node) {
const parent = node.parent;
if (parent.kind === SyntaxKind.PropertyAssignment ||
parent.kind === SyntaxKind.ExportAssignment ||
parent.kind === SyntaxKind.PropertyDeclaration ||
parent.kind === SyntaxKind.ExpressionStatement && node.kind === SyntaxKind.PropertyAccessExpression ||
getNestedModuleDeclaration(parent) ||
Expand Down
15 changes: 15 additions & 0 deletions tests/baselines/reference/exportDefaultWithJSDoc1.symbols
@@ -0,0 +1,15 @@
=== tests/cases/compiler/a.js ===
/**
No type information for this code. * A number, or a string containing a number.
No type information for this code. * @typedef {(number|string)} NumberLike
No type information for this code. */
No type information for this code.
No type information for this code./** @type {NumberLike[]} */export default ([ ]);
No type information for this code.
No type information for this code.=== tests/cases/compiler/b.ts ===
import A from './a'
>A : Symbol(A, Decl(b.ts, 0, 6))

A[0]
>A : Symbol(A, Decl(b.ts, 0, 6))

19 changes: 19 additions & 0 deletions tests/baselines/reference/exportDefaultWithJSDoc1.types
@@ -0,0 +1,19 @@
=== tests/cases/compiler/a.js ===
/**
* A number, or a string containing a number.
* @typedef {(number|string)} NumberLike
*/

/** @type {NumberLike[]} */export default ([ ]);
>([ ]) : (string | number)[]
>[ ] : undefined[]

=== tests/cases/compiler/b.ts ===
import A from './a'
>A : (string | number)[]

A[0]
>A[0] : string | number
>A : (string | number)[]
>0 : 0

15 changes: 15 additions & 0 deletions tests/baselines/reference/exportDefaultWithJSDoc2.symbols
@@ -0,0 +1,15 @@
=== tests/cases/compiler/a.js ===
/**
No type information for this code. * A number, or a string containing a number.
No type information for this code. * @typedef {(number|string)} NumberLike
No type information for this code. */
No type information for this code.
No type information for this code.export default /** @type {NumberLike[]} */([ ]);
No type information for this code.
No type information for this code.=== tests/cases/compiler/b.ts ===
import A from './a'
>A : Symbol(A, Decl(b.ts, 0, 6))

A[0]
>A : Symbol(A, Decl(b.ts, 0, 6))

19 changes: 19 additions & 0 deletions tests/baselines/reference/exportDefaultWithJSDoc2.types
@@ -0,0 +1,19 @@
=== tests/cases/compiler/a.js ===
/**
* A number, or a string containing a number.
* @typedef {(number|string)} NumberLike
*/

export default /** @type {NumberLike[]} */([ ]);
>([ ]) : (string | number)[]
>[ ] : undefined[]

=== tests/cases/compiler/b.ts ===
import A from './a'
>A : (string | number)[]

A[0]
>A[0] : string | number
>A : (string | number)[]
>0 : 0

16 changes: 16 additions & 0 deletions tests/cases/compiler/exportDefaultWithJSDoc1.ts
@@ -0,0 +1,16 @@

// @allowJs: true
// @checkJs: true
// @noEmit: true

/**
* A number, or a string containing a number.
* @typedef {(number|string)} NumberLike
*/

// @Filename: a.js
/** @type {NumberLike[]} */export default ([ ]);

// @Filename: b.ts
import A from './a'
A[0]
16 changes: 16 additions & 0 deletions tests/cases/compiler/exportDefaultWithJSDoc2.ts
@@ -0,0 +1,16 @@

// @allowJs: true
// @checkJs: true
// @noEmit: true

/**
* A number, or a string containing a number.
* @typedef {(number|string)} NumberLike
*/

// @Filename: a.js
export default /** @type {NumberLike[]} */([ ]);

// @Filename: b.ts
import A from './a'
A[0]

0 comments on commit b8e3c41

Please sign in to comment.