diff --git a/src/comments.js b/src/comments.js index 638821068..515ed12d3 100644 --- a/src/comments.js +++ b/src/comments.js @@ -369,6 +369,13 @@ function addCommentHelper(node, comment) { const comments = node.comments || (node.comments = []); comments.push(comment); comment.printed = false; + + // For some reason, TypeScript parses `// x` inside of JSXText as a comment + // We already "print" it via the raw text, we don't need to re-print it as a + // comment + if (node.type === "JSXText") { + comment.printed = true; + } } function addLeadingComment(node, comment) { diff --git a/tests/typescript_comments/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_comments/__snapshots__/jsfmt.spec.js.snap index 537599567..d4bfd9635 100644 --- a/tests/typescript_comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_comments/__snapshots__/jsfmt.spec.js.snap @@ -21,6 +21,29 @@ abstract class AbstractRule { `; +exports[`jsx.ts 1`] = ` +var example1 =