Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transformer): support generate proper binding name from ChainExpression #7326

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/oxc_traverse/src/ast_operations/gather_node_parts.rs
Original file line number Diff line number Diff line change
@@ -186,6 +186,7 @@ impl<'a> GatherNodeParts<'a> for Expression<'a> {
Self::ParenthesizedExpression(expr) => expr.gather(f),
Self::UnaryExpression(expr) => expr.gather(f),
Self::UpdateExpression(expr) => expr.gather(f),
Self::ChainExpression(expr) => expr.gather(f),
Self::MetaProperty(expr) => expr.gather(f),
Self::JSXElement(expr) => expr.gather(f),
Self::JSXFragment(expr) => expr.gather(f),
@@ -198,6 +199,21 @@ impl<'a> GatherNodeParts<'a> for Expression<'a> {
}
}

impl<'a> GatherNodeParts<'a> for ChainExpression<'a> {
fn gather<F: FnMut(&str)>(&self, f: &mut F) {
self.expression.gather(f);
}
}

impl<'a> GatherNodeParts<'a> for ChainElement<'a> {
fn gather<F: FnMut(&str)>(&self, f: &mut F) {
match self {
ChainElement::CallExpression(expr) => expr.gather(f),
expr => expr.to_member_expression().gather(f),
}
}
}

impl<'a> GatherNodeParts<'a> for MemberExpression<'a> {
fn gather<F: FnMut(&str)>(&self, f: &mut F) {
match self {
6 changes: 3 additions & 3 deletions tasks/coverage/snapshots/semantic_typescript.snap
Original file line number Diff line number Diff line change
@@ -47454,11 +47454,11 @@ rebuilt : ScopeId(0): []
tasks/coverage/typescript/tests/cases/conformance/expressions/nullishCoalescingOperator/nullishCoalescingOperator12.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["obj"]
rebuilt : ScopeId(0): ["_ref", "obj"]
rebuilt : ScopeId(0): ["_obj$arr", "obj"]
Bindings mismatch:
after transform: ScopeId(1): ["_ref", "i"]
after transform: ScopeId(1): ["_obj$arr", "i"]
rebuilt : ScopeId(1): ["i"]
Symbol scope ID mismatch for "_ref":
Symbol scope ID mismatch for "_obj$arr":
after transform: SymbolId(2): ScopeId(1)
rebuilt : SymbolId(0): ScopeId(0)