clang-format: [JS] support import/export type
authorJan Kuhle <jankuehle@google.com>
Wed, 10 May 2023 13:11:50 +0000 (15:11 +0200)
committerKrasimir Georgiev <krasimir@google.com>
Wed, 10 May 2023 13:27:03 +0000 (15:27 +0200)
commit34b422bafbd934ee3c644fd7a8f0b6803976c818
treea90f600db1dc1bab0968b3f1dfefd24325b89738
parenta414db1d8e3173faca024d4532a4c655a1fe02c0
clang-format: [JS] support import/export type

Contributed by @jankuehle!

Users can choose to only import/export the type of the symbol (not value nor namespace) by adding a `type` keyword, e.g.:

```
import type {x} from 'y';
import {type x} from 'y';
export type {x};
export {type x};
```

Previously, this was not handled and would:
- Terminate import sorting
- Remove the space before the curly bracket in `export type {`

With this change, both formatting and import sorting work as expected.

Reviewed By: MyDeveloperDay, krasimir

Differential Revision: https://reviews.llvm.org/D150116
clang/lib/Format/SortJavaScriptImports.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestJS.cpp
clang/unittests/Format/SortImportsTestJS.cpp