clang-format: [JS] avoid indent after ambient function declarations.
Summary:
Before:
declare function foo();
let x = 1;
After:
declare function foo();
let x = 1;
The problem was that clang-format would unconditionally try to parse a child block, even though ambient function declarations do not have a body (similar to forward declarations).
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D28246
llvm-svn: 290959
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 6f494db..90c9931 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -377,6 +377,16 @@
"declare function\n"
"x();", // TODO(martinprobst): should ideally be indented.
NineCols);
+ verifyFormat("declare function foo();\n"
+ "let x = 1;\n");
+ verifyFormat("declare function foo(): string;\n"
+ "let x = 1;\n");
+ verifyFormat("declare function foo(): {x: number};\n"
+ "let x = 1;\n");
+ verifyFormat("declare class X {}\n"
+ "let x = 1;\n");
+ verifyFormat("declare interface Y {}\n"
+ "let x = 1;\n");
verifyFormat(
"declare enum X {\n"
"}",