Repository: jlongster/prettier (js)

Issue:
Unprinted comment after `export`
```js
export/* missing comment */{};
```

```
Error: Comment "missing comment" was not printed. Please report this error!
```

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22export%2F*%20missing%20comment%20*%2F%7B%7D%3B%5Cn%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%2C%22jsxBracketSameLine%22%3Afalse%2C%22doc%22%3Afalse%7D%7D

Pull request description:
Fix missing dangling comment in exports
This should fix #698.

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index 84afe6be3..ef6164a30 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -419,6 +419,7 @@ FPp.needsParens = function(assumeExpressionContext) {
         case "LogicalExpression":
         case "NewExpression":
         case "ExportDefaultDeclaration":
+        case "AwaitExpression":
           return true;
 
         case "CallExpression":
diff --git a/src/printer.js b/src/printer.js
index 80b59eb91..8e4560488 100644
--- a/src/printer.js
+++ b/src/printer.js
@@ -2025,6 +2025,8 @@ function printExportDeclaration(path, options, print) {
     parts.push("default ");
   }
 
+  parts.push(comments.printDanglingComments(path, options, /* sameIndent */ true));
+
   if (decl.declaration) {
     parts.push(path.call(print, "declaration"));
 


Test patch:
diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap
index 208c7fca7..4496f3b53 100644
--- a/tests/async/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/async/__snapshots__/jsfmt.spec.js.snap
@@ -18,9 +18,19 @@ exports[`test conditional-expression.js 1`] = `
 "async function f() {
   const result = typeof fn === \'function\' ? await fn() : null;
 }
+
+(async function() {
+  console.log(
+    await (true ? Promise.resolve(\"A\") : Promise.resolve(\"B\"))
+  );
+})()
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 async function f() {
   const result = typeof fn === \"function\" ? await fn() : null;
 }
+
+(async function() {
+  console.log(await (true ? Promise.resolve(\"A\") : Promise.resolve(\"B\")));
+})();
 "
 `;
diff --git a/tests/async/conditional-expression.js b/tests/async/conditional-expression.js
index 532c66d6a..73d846394 100644
--- a/tests/async/conditional-expression.js
+++ b/tests/async/conditional-expression.js
@@ -1,3 +1,9 @@
 async function f() {
   const result = typeof fn === 'function' ? await fn() : null;
 }
+
+(async function() {
+  console.log(
+    await (true ? Promise.resolve("A") : Promise.resolve("B"))
+  );
+})()
diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap
index d70983ab8..9506de259 100644
--- a/tests/comments/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap
@@ -38,6 +38,7 @@ function x() {
   /* dangling */
 }
 declare class Foo extends Qux<string> {/* dangling */}
+export /* dangling */{};
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 var x = {
   /* dangling */
@@ -54,6 +55,7 @@ function x() {
 declare class Foo extends Qux<string> {
   /* dangling */
 }
+export /* dangling */{};
 "
 `;
 
@@ -67,6 +69,7 @@ function x() {
   /* dangling */
 }
 declare class Foo extends Qux<string> {/* dangling */}
+export /* dangling */{};
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 var x = {
   /* dangling */
@@ -83,6 +86,7 @@ function x() {
 declare class Foo extends Qux<string> {
   /* dangling */
 }
+export /* dangling */{};
 "
 `;
 
diff --git a/tests/comments/dangling.js b/tests/comments/dangling.js
index 22208dee5..f041ce3dc 100644
--- a/tests/comments/dangling.js
+++ b/tests/comments/dangling.js
@@ -7,3 +7,4 @@ function x() {
   /* dangling */
 }
 declare class Foo extends Qux<string> {/* dangling */}
+export /* dangling */{};