Commit 588577c
authored
feat(es/parser): support Flow declare export default interface strip path (#11692)
## Summary
This PR completes the remaining Flow strip parser gap for `declare
export default interface ...`.
### What changed
- Added a Flow-specific `declare export default` branch for `interface`
in `swc_ecma_parser`.
- Parses `declare export default interface Foo { ... }` as
`Decl::TsInterface`, then marks it `declare` via the existing
`make_decl_declare` path.
- Kept existing fallback behavior for `declare export default <type>;`
unchanged.
- Added a new parser fixture suite:
-
`crates/swc_ecma_parser/tests/flow/declare-export-default-interface/basic.js`
- Extended flow-strip e2e fixture input:
- `crates/swc/tests/fixture/flow-strip/input/index.js`
## Scope notes
- Intentionally **not** changing behavior for:
- `declare export default opaque type ...`
- semicolon-separated declare-export specifier lists like `declare
export { Foo; Bar }`
## Testing
- `git submodule update --init --recursive`
- `UPDATE=1 cargo test -p swc_ecma_parser --test flow --features flow --
--ignored`
- `cargo test -p swc_ecma_parser --test flow --features flow --
--ignored`
- `UPDATE=1 cargo test -p swc --test projects -F flow -- --ignored
flow_strip`
- `cargo test -p swc --test projects -F flow -- --ignored flow_strip`
- `cargo fmt --all`
- `cargo clippy --all --all-targets -- -D warnings`
- `cargo test -p swc_ecma_parser`
- `cargo test -p swc` *(fails in `source_map` tests in this environment
due missing Node module `sourcemap-validator`)*1 parent 99e61c4 commit 588577c
4 files changed
Lines changed: 89 additions & 0 deletions
File tree
- crates
- swc_ecma_parser
- src/parser
- tests/flow/declare-export-default-interface
- swc/tests/fixture/flow-strip/input
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3060 | 3060 | | |
3061 | 3061 | | |
3062 | 3062 | | |
| 3063 | + | |
| 3064 | + | |
| 3065 | + | |
| 3066 | + | |
| 3067 | + | |
| 3068 | + | |
| 3069 | + | |
| 3070 | + | |
| 3071 | + | |
3063 | 3072 | | |
3064 | 3073 | | |
3065 | 3074 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
0 commit comments