clang-format: [JS] terminate import sorting on export type X = Y
Contributed by @jankuehle! https://reviews.llvm.org/D150116 introduced a bug. `export type X = Y` was considered an export declaration and took part in import sorting. This is not correct. With this change `export type X = Y` properly terminates import sorting. Reviewed By: krasimir Differential Revision: https://reviews.llvm.org/D150563
This commit is contained in:
committed by
Krasimir Georgiev
parent
1f479c1e46
commit
e1f34b735b
@@ -517,7 +517,7 @@ private:
|
||||
}
|
||||
|
||||
// eat a potential "import X, " prefix.
|
||||
if (Current->is(tok::identifier)) {
|
||||
if (!Reference.IsExport && Current->is(tok::identifier)) {
|
||||
Reference.DefaultImport = Current->TokenText;
|
||||
nextToken();
|
||||
if (Current->is(Keywords.kw_from))
|
||||
|
||||
@@ -503,6 +503,15 @@ TEST_F(SortImportsTestJS, ImportExportType) {
|
||||
verifySort("export {A, type B} from 'foo';\n",
|
||||
"export {A} from 'foo';\n"
|
||||
"export {type B} from 'foo';");
|
||||
|
||||
// `export type X = Y;` should terminate import sorting. The following export
|
||||
// statements should therefore not merge.
|
||||
verifySort("export type A = B;\n"
|
||||
"export {X};\n"
|
||||
"export {Y};\n",
|
||||
"export type A = B;\n"
|
||||
"export {X};\n"
|
||||
"export {Y};\n");
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
Reference in New Issue
Block a user