diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 9f79ba60f39febef6e7728700d5dcee74931369b..94dccc6e02b04fdd36560bf318e70d2e74b01d7a 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -364,7 +364,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { // We exclude + and - as they can be ObjC visibility modifiers. ProbablyBracedList = (Style.Language == FormatStyle::LK_JavaScript && - NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in)) || + NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in, + Keywords.kw_as)) || NextTok->isOneOf(tok::comma, tok::period, tok::colon, tok::r_paren, tok::r_square, tok::l_brace, tok::l_square, tok::l_paren, tok::ellipsis) || diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 2819383a35851b214079ecd1d6abb7fb674e9e99..838caffc7087b1befdd532b1452aa2f3c8e8d34a 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -1218,6 +1218,7 @@ TEST_F(FormatTestJS, CastSyntax) { " 1, //\n" " 2\n" "];"); + verifyFormat("var x = [{x: 1} as type];"); } TEST_F(FormatTestJS, TypeArguments) {