Skip to content

Commit

Permalink
Add test for babel/babel#12054
Browse files Browse the repository at this point in the history
  • Loading branch information
sosukesuzuki committed Oct 15, 2020
1 parent 7417d90 commit cf0ed63
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/language-js/printer-estree.js
Expand Up @@ -913,7 +913,8 @@ function printPathNoParens(path, options, print, args) {
parent.type === "DoWhileStatement" ||
parent.type === "DoExpression" ||
(parent.type === "CatchClause" && !parentParent.finalizer) ||
parent.type === "TSModuleDeclaration")
parent.type === "TSModuleDeclaration" ||
parent.type === "TSDeclareFunction")
) {
return "{}";
}
Expand Down
22 changes: 22 additions & 0 deletions tests/typescript/declare/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -72,6 +72,28 @@ declare function f([]?);
================================================================================
`;

exports[`declare_function_with_body.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
// Invalid, but recoverable
declare function foo() {}
declare function bar() {
// comment
}
=====================================output=====================================
// Invalid, but recoverable
declare function foo() {};
declare function bar() {
// comment
};
================================================================================
`;

exports[`declare_interface.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
Expand Down
5 changes: 5 additions & 0 deletions tests/typescript/declare/declare_function_with_body.ts
@@ -0,0 +1,5 @@
// Invalid, but recoverable
declare function foo() {}
declare function bar() {
// comment
}

0 comments on commit cf0ed63

Please sign in to comment.