clang-format: [JS] handle object types in extends positions.
Summary:
clang-format would previously drop the whitespace after `extends` in code such as:
class Foo extends {} {}
Where the first set of curly braces is an inline object literal type.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D36131
llvm-svn: 309695
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index ba922b0..d91df54 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1400,6 +1400,17 @@
"}");
}
+TEST_F(FormatTestJS, ObjectTypesInExtendsImplements) {
+ verifyFormat("class C extends {} {}");
+ verifyFormat("class C implements {bar: number} {}");
+ // Somewhat odd, but probably closest to reasonable formatting?
+ verifyFormat("class C implements {\n"
+ " bar: number,\n"
+ " baz: string,\n"
+ "} {}");
+ verifyFormat("class C<P extends {}> {}");
+}
+
TEST_F(FormatTestJS, EnumDeclarations) {
verifyFormat("enum Foo {\n"
" A = 1,\n"