forked from OSchip/llvm-project
clang-format: [JS/TypeScript] Support "enum" as an optional property name, too.
Before: enum?: string []; After: enum?: string[]; llvm-svn: 259628
This commit is contained in:
parent
305bf59335
commit
8737930cac
|
@ -1550,7 +1550,8 @@ bool UnwrappedLineParser::parseEnum() {
|
|||
// In TypeScript, "enum" can also be used as property name, e.g. in interface
|
||||
// declarations. An "enum" keyword followed by a colon would be a syntax
|
||||
// error and thus assume it is just an identifier.
|
||||
if (Style.Language == FormatStyle::LK_JavaScript && FormatTok->is(tok::colon))
|
||||
if (Style.Language == FormatStyle::LK_JavaScript &&
|
||||
FormatTok->isOneOf(tok::colon, tok::question))
|
||||
return false;
|
||||
|
||||
// Eat up enum class ...
|
||||
|
|
|
@ -804,6 +804,7 @@ TEST_F(FormatTestJS, InterfaceDeclarations) {
|
|||
verifyFormat("interface I {\n"
|
||||
" x: string;\n"
|
||||
" enum: string[];\n"
|
||||
" enum?: string[];\n"
|
||||
"}\n"
|
||||
"var y;");
|
||||
// Ensure that state is reset after parsing the interface.
|
||||
|
|
Loading…
Reference in New Issue