Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -639,7 +639,7 @@ } // Declarations cannot be conditional expressions, this can only be part // of a type declaration. - if (Line.MustBeDeclaration && !Contexts.back().IsExpression && + if (!Contexts.back().IsExpression && Style.Language == FormatStyle::LK_JavaScript) break; parseConditional(); Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1351,7 +1351,7 @@ TEST_F(FormatTestJS, Conditional) { verifyFormat("y = x ? 1 : 2;"); - verifyFormat("x ? 1 : 2;"); + verifyFormat("x ? 1: 2;"); // Known issue with top level conditionals. verifyFormat("class Foo {\n" " field = true ? 1 : 2;\n" " method(a = true ? 1 : 2) {}\n"