Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1757,6 +1757,14 @@ return false; if (Left.is(TT_TemplateCloser) && Right.is(tok::l_square)) return false; + if (Left.is(TT_TemplateCloser) && + Style.Language == FormatStyle::LK_JavaScript && + !Right.isOneOf(tok::l_brace, tok::comma, tok::l_square, + Keywords.kw_implements, Keywords.kw_extends)) + // Type assertions ('expr') are not followed by whitespace. Other + // locations that should have whitespace following are identified by the + // above set of follower tokens. + return false; return true; } Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -613,5 +613,17 @@ verifyFormat("var x = `hello` == `hello`;"); } +TEST_F(FormatTestJS, CastSyntax) { + verifyFormat("var x = foo;"); +} + +TEST_F(FormatTestJS, TypeArguments) { + verifyFormat("class X {}"); + verifyFormat("new X();"); + verifyFormat("foo(a);"); + verifyFormat("var x: X[];"); + verifyFormat("class C extends D implements F, H {}"); +} + } // end namespace tooling } // end namespace clang