[all-commits] [llvm/llvm-project] 34b422: clang-format: [JS] support import/export type

Jan Kühle via All-commits all-commits at lists.llvm.org
Wed May 10 06:28:35 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 34b422bafbd934ee3c644fd7a8f0b6803976c818
      https://github.com/llvm/llvm-project/commit/34b422bafbd934ee3c644fd7a8f0b6803976c818
  Author: Jan Kuhle <jankuehle at google.com>
  Date:   2023-05-10 (Wed, 10 May 2023)

  Changed paths:
    M clang/lib/Format/SortJavaScriptImports.cpp
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/FormatTestJS.cpp
    M clang/unittests/Format/SortImportsTestJS.cpp

  Log Message:
  -----------
  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




More information about the All-commits mailing list