mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
## Summary
This extends Flow strip compatibility in `swc_ecma_parser` for remaining
`declare export` forms by normalizing type-only declarations into
synthetic `TsTypeAlias` nodes.
### Parser changes
- Added Flow `declare export` handling for:
- `declare export { ... };`
- `declare export { ... } from "...";`
- `declare export * from "...";`
- `declare export * as ns from "...";`
- These declarations are normalized to synthetic aliases with unique
ids:
- `__flow_declare_export_<bytepos>`
- Enhanced `declare export default` handling:
- anonymous `function` / `async function` / `class` are now accepted and
normalized to synthetic `__flow_default_export: any`
- named default function/class behavior is preserved as `declare`
declarations
- `declare export default interface` remains unsupported
### Fixtures
Added parser Flow fixtures:
- `crates/swc_ecma_parser/tests/flow/declare-export-specifiers/basic.js`
-
`crates/swc_ecma_parser/tests/flow/declare-export-default-anon/basic.js`
Expanded flow-strip input fixture:
- `crates/swc/tests/fixture/flow-strip/input/index.js`
## Validation
- `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`