Summary:
Wrapping between the type name and the array type indicator creates
invalid syntax in TypeScript.
Before:
const xIsALongIdent:
YJustBarelyFitsLinex
[]; // illegal syntax.
After:
const xIsALongIdent:
YJustBarelyFitsLinex[];
Reviewers: djasper
Subscribers: klimek
Differential Revision: https://reviews.llvm.org/D40436
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318959
91177308-0d34-0410-b5e6-
96231b3b80d8
Keywords.kw_readonly, Keywords.kw_abstract,
Keywords.kw_get, Keywords.kw_set))
return false; // Otherwise automatic semicolon insertion would trigger.
+ if (Left.Tok.getIdentifierInfo() &&
+ Right.startsSequence(tok::l_square, tok::r_square))
+ return false; // breaking in "foo[]" creates illegal TS type syntax.
if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
return false;
if (Left.is(TT_JsTypeColon))
verifyFormat(
"var someValue = (v as aaaaaaaaaaaaaaaaaaaa<T>[])\n"
" .someFunction(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+ verifyFormat("const xIsALongIdent:\n"" YJustBarelyFitsLinex[];",
+ getGoogleJSStyleWithColumns(20));
}
TEST_F(FormatTestJS, UnionIntersectionTypes) {