Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -1034,7 +1034,8 @@ if (Style.Language == FormatStyle::LK_JavaScript) { if (Current.is(tok::exclaim)) { if (Current.Previous && - (Current.Previous->isOneOf(tok::identifier, tok::r_paren, + (Current.Previous->Tok.getIdentifierInfo() || + Current.Previous->isOneOf(tok::identifier, tok::r_paren, tok::r_square, tok::r_brace) || Current.Previous->Tok.isLiteral())) { Current.Type = TT_JsNonNullAssertion; Index: cfe/trunk/unittests/Format/FormatTestJS.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTestJS.cpp +++ cfe/trunk/unittests/Format/FormatTestJS.cpp @@ -1799,6 +1799,7 @@ " .foo()!\n" " .foo()!;\n", getGoogleJSStyleWithColumns(20)); + verifyFormat("let x = namespace!;\n"); } TEST_F(FormatTestJS, Conditional) {