diff --git a/src/printer.js b/src/printer.js index 21f9ec220..13757260d 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2453,7 +2453,7 @@ function genericPrintNoParens(path, options, print, args) { if (n.typeAnnotation) { parts.push(": ", path.call(print, "typeAnnotation")); } - return concat(parts); + return group(concat(parts)); case "TSNamespaceExportDeclaration": if (n.declaration) { // Temporary fix until https://github.com/eslint/typescript-eslint-parser/issues/263 diff --git a/tests/typescript_interface/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_interface/__snapshots__/jsfmt.spec.js.snap index e6c2d8ae8..b20f63d18 100644 --- a/tests/typescript_interface/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_interface/__snapshots__/jsfmt.spec.js.snap @@ -9,6 +9,19 @@ abstract interface I {} `; +exports[`comments.js 1`] = ` +interface ScreenObject { + // I make things weird. + at(point: Point): Screen | undefined; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +interface ScreenObject { + // I make things weird. + at(point: Point): Screen | undefined; +} + +`; + exports[`separator.ts 1`] = ` declare module 'selenium-webdriver' { export const until: { diff --git a/tests/typescript_interface/comments.js b/tests/typescript_interface/comments.js new file mode 100644 index 000000000..513e607bd --- /dev/null +++ b/tests/typescript_interface/comments.js @@ -0,0 +1,4 @@ +interface ScreenObject { + // I make things weird. + at(point: Point): Screen | undefined; +}