diff --git a/src/printer.js b/src/printer.js index b526894d8..fd6f37f6a 100644 --- a/src/printer.js +++ b/src/printer.js @@ -3386,7 +3386,20 @@ function printExportDeclaration(path, options, print) { const parts = ["export "]; if (decl["default"] || decl.type === "ExportDefaultDeclaration") { - parts.push("default "); + // Temp fix, delete after https://github.com/eslint/typescript-eslint-parser/issues/304 + if ( + decl.declaration && + /=/.test( + options.originalText.slice( + util.locStart(decl), + util.locStart(decl.declaration) + ) + ) + ) { + parts.push("= "); + } else { + parts.push("default "); + } } parts.push( diff --git a/tests/typescript_export/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_export/__snapshots__/jsfmt.spec.js.snap index 3758849a7..1bde3273f 100644 --- a/tests/typescript_export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_export/__snapshots__/jsfmt.spec.js.snap @@ -8,3 +8,22 @@ export function match(): string /* the matching pattern */ a; `; + +exports[`export.ts 1`] = ` +declare module "hello" { + export default Hello; +} + +declare module "hello" { + export = Hello; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +declare module "hello" { + export default Hello; +} + +declare module "hello" { + export = Hello; +} + +`; diff --git a/tests/typescript_export/export.ts b/tests/typescript_export/export.ts new file mode 100644 index 000000000..d8b4d58e7 --- /dev/null +++ b/tests/typescript_export/export.ts @@ -0,0 +1,7 @@ +declare module "hello" { + export default Hello; +} + +declare module "hello" { + export = Hello; +}