oxc-project / oxc

âš“ A collection of JavaScript tools written in Rust.
https://oxc.rs
MIT License
12.5k stars 458 forks source link

Add API to `Semantic` to remove unresolved references in bulk #5322

Open overlookmotel opened 2 months ago

overlookmotel commented 2 months ago

5305 added ScopeTree::delete_root_unresolved_reference API to delete an unresolved reference.

@Dunqing said in https://github.com/oxc-project/oxc/pull/5305#pullrequestreview-2267485901:

Upon further reflection, I think we may also need to add a high-level API to remove unresolved_references. We usually may need to remove a whole expression or type_annotation, and we also need to figure out if the references are resolved or unresolved. It's painful to remove these 🙃

I agree with Dunqing that this API is needed. Opening this issue to discuss what it'd look like / how it'd work.

Dunqing commented 1 month ago

I have written a BindingMover to move all bindings to a specified scope here. I think we can take a similar way to remove symbol and reference https://github.com/oxc-project/oxc/blob/410d5bb3c4bf2098f4f222659def3569fc715cc8/crates/oxc_transformer/src/es2017/async_to_generator.rs#L679-L703