diff --git a/src/printer.js b/src/printer.js index b8270ccd6..a720bf89d 100644 --- a/src/printer.js +++ b/src/printer.js @@ -383,6 +383,9 @@ function genericPrintNoParens(path, options, print, args) { parts.push("declare "); } parts.push(printFunctionDeclaration(path, print, options)); + if (n.type === "TSNamespaceFunctionDeclaration" && !n.body) { + parts.push(semi); + } return concat(parts); case "ArrowFunctionExpression": { if (n.async) { diff --git a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap index 51d9ab59b..c3dc4c877 100644 --- a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap @@ -772,7 +772,7 @@ namespace glo_M1_public { } declare module "glo_M2_public" { - export function f1() + export function f1(); export class c1 {} export var v1: { new (): c1 }; export var v2: c1; diff --git a/tests/typescript_method/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_method/__snapshots__/jsfmt.spec.js.snap index c821e79a4..6db461a4b 100644 --- a/tests/typescript_method/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_method/__snapshots__/jsfmt.spec.js.snap @@ -1,5 +1,18 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`semi.js 1`] = ` +declare module 'foo' { + function foo(namespace: string): void; + function bar(namespace: string): void; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +declare module "foo" { + function foo(namespace: string): void; + function bar(namespace: string): void; +} + +`; + exports[`type_literal_optional_method.ts 1`] = ` var v: { e?(): number }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/typescript_method/semi.js b/tests/typescript_method/semi.js new file mode 100644 index 000000000..978f1c29b --- /dev/null +++ b/tests/typescript_method/semi.js @@ -0,0 +1,4 @@ +declare module 'foo' { + function foo(namespace: string): void; + function bar(namespace: string): void; +}