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

fix(binder): bind declare class #8038

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
22 changes: 8 additions & 14 deletions crates/oxc_semantic/src/binder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,14 @@ impl<'a> Binder<'a> for VariableDeclarator<'a> {

impl<'a> Binder<'a> for Class<'a> {
fn bind(&self, builder: &mut SemanticBuilder) {
if !self.declare {
let Some(ident) = &self.id else { return };
let symbol_id = builder.declare_symbol(
ident.span,
&ident.name,
SymbolFlags::Class,
if self.is_declaration() {
SymbolFlags::ClassExcludes
} else {
SymbolFlags::empty()
},
);
ident.symbol_id.set(Some(symbol_id));
}
let Some(ident) = &self.id else { return };
let symbol_id = builder.declare_symbol(
ident.span,
&ident.name,
SymbolFlags::Class,
if self.is_declaration() { SymbolFlags::ClassExcludes } else { SymbolFlags::empty() },
);
ident.symbol_id.set(Some(symbol_id));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
source: crates/oxc_semantic/tests/main.rs
input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/class/declaration/declare.ts
snapshot_kind: text
---
[
{
"children": [
{
"children": [],
"flags": "ScopeFlags(StrictMode)",
"id": 1,
"node": "Class(A)",
"symbols": []
},
{
"children": [],
"flags": "ScopeFlags(StrictMode)",
"id": 2,
"node": "Class(B)",
"symbols": []
}
],
"flags": "ScopeFlags(StrictMode | Top)",
"id": 0,
"node": "Program",
"symbols": [
{
"flags": "SymbolFlags(Class)",
"id": 0,
"name": "A",
"node": "Class(A)",
"references": []
},
{
"flags": "SymbolFlags(Class)",
"id": 1,
"name": "B",
"node": "Class(B)",
"references": []
}
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare class A { }

class B { }
Loading