diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index fe7e001daaf74d6b5347b2aa0837a210cd0cd9d1..9c4a6268abe712adbf7c6a389f4412d870b55b48 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -2373,6 +2373,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
       return Style.BreakBeforeBinaryOperators == FormatStyle::BOS_None;
     if (Right.is(Keywords.kw_in))
       return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None;
+    if (Right.is(Keywords.kw_as))
+      return false; // must not break before as in 'x as type' casts
   }
 
   if (Left.is(tok::at))
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index f71571c16a32207afb7a410ec95eab1d738d3b39..4feb55dae2496533ffe597289351634a27acaaac 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -1051,8 +1051,8 @@ TEST_F(FormatTestJS, Modules) {
   // ... but not if from is just an identifier.
   verifyFormat("export {\n"
                "  from as from,\n"
-               "  someSurprisinglyLongVariable\n"
-               "      as from\n"
+               "  someSurprisinglyLongVariable as\n"
+               "      from\n"
                "};",
                getGoogleJSStyleWithColumns(20));
   verifyFormat("export class C {\n"
@@ -1205,6 +1205,9 @@ TEST_F(FormatTestJS, TemplateStrings) {
 TEST_F(FormatTestJS, CastSyntax) {
   verifyFormat("var x = <type>foo;");
   verifyFormat("var x = foo as type;");
+  verifyFormat("let x = (a + b) as\n"
+               "    LongTypeIsLong;",
+               getGoogleJSStyleWithColumns(20));
   verifyFormat("foo = <Bar[]>[\n"
                "  1,  //\n"
                "  2\n"