[PATCH] D144317: [clang-format] Fix handling of TypeScript tuples with optional last member
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 21 02:52:33 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG801bd3265362: [clalng-format] Fix handling of TypeScript tuples with optional last member (authored by taymonbeal, committed by owenpan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144317/new/
https://reviews.llvm.org/D144317
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestJS.cpp
Index: clang/unittests/Format/FormatTestJS.cpp
===================================================================
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2221,6 +2221,7 @@
" aaaaaaaaaaaaaaa?: boolean,\n"
" aaaaaa?: List<string>\n"
"}) {}");
+ verifyFormat("type X = [y?];");
}
TEST_F(FormatTestJS, IndexSignature) {
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1248,7 +1248,7 @@
case tok::question:
if (Style.isJavaScript() && Tok->Next &&
Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
- tok::r_brace)) {
+ tok::r_brace, tok::r_square)) {
// Question marks before semicolons, colons, etc. indicate optional
// types (fields, parameters), e.g.
// function(x?: string, y?) {...}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144317.499094.patch
Type: text/x-patch
Size: 1065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230221/66667d75/attachment.bin>
More information about the cfe-commits
mailing list