Skip to content

Commit

Permalink
fix: trailing comment of last node.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo Maruyama committed Mar 22, 2015
1 parent 4ff770a commit 419711d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/Converter.js
Expand Up @@ -72,17 +72,17 @@ export default class Converter {
let lastNode6 = ast6.body[ast6.body.length - 1];

for (let node6 of ast6.body) {
if (node6 !== lastNode6) {
node6.trailingComments = [];
}

if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node6.type)) {
let exportNode = node6;
node6 = exportNode.declaration;
node6.leadingComments = exportNode.leadingComments;
node6.trailingComments = exportNode.trailingComments;
}

if (node6 !== lastNode6) {
node6.trailingComments = [];
}

switch (node6.type) {
case 'ClassDeclaration':
let node5 = new FunctionDeclarationNode(node6.id.name);
Expand All @@ -95,7 +95,6 @@ export default class Converter {
default:
if (node6.params) node6.params = [];
if (node6.defaults) node6.defaults = [];
node6.trailingComments = [];
ast5.body.push(node6);
break;
}
Expand Down
4 changes: 3 additions & 1 deletion test/expect/sample.js
Expand Up @@ -71,4 +71,6 @@ var myVar = 100;
* this is myMember.
* @type {number}
*/
window.myMember = 100;
window.myMember = 100; /**
* @typedef {number|string} TypeX
*/
4 changes: 4 additions & 0 deletions test/fixture/sample.js
Expand Up @@ -99,3 +99,7 @@ export var myVar = 100;
* @type {number}
*/
window.myMember = 100;

/**
* @typedef {number|string} TypeX
*/

0 comments on commit 419711d

Please sign in to comment.