fix jsdoc iterator on expression of export assignment (#30558)

This commit is contained in:
Wenlu Wang 2019-04-25 16:53:06 -05:00 committed by Ryan Cavanaugh
parent 867c992021
commit b8e3c41ee1
7 changed files with 101 additions and 0 deletions

View File

@ -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) ||

View File

@ -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))

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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]

View File

@ -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]