[PATCH] D146247: [clang-format] Support TypeScript satisfies operator

Taymon A. Beal via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 17 11:40:25 PDT 2023


taymonbeal updated this revision to Diff 506153.
taymonbeal added a comment.

Add release notes and unit test in TokenAnnotatorTest.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146247/new/

https://reviews.llvm.org/D146247

Files:
  clang/docs/ReleaseNotes.rst
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===================================================================
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1434,6 +1434,20 @@
   EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsTypeScriptSatisfiesOperator) {
+  auto Tokens = annotate("let x = foo satisfies Type;",
+                         getGoogleStyle(FormatStyle::LK_JavaScript));
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[2], tok::equal, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[6], tok::semi, TT_Unknown);
+  EXPECT_TOKEN(Tokens[7], tok::eof, TT_Unknown);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -326,6 +326,7 @@
   Compared to ``NextLine`` style, ``NextLineOnly`` style will not try to
   put the initializers on the current line first, instead, it will try to
   put the initializers on the next line only.
+- Add support for the ``satisfies`` operator introduced in TypeScript 4.9.
 
 libclang
 --------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146247.506153.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230317/a999618b/attachment.bin>


More information about the cfe-commits mailing list