Skip to content

Commit

Permalink
fix(transformer/typescript): remove accessibility from `AccessorPrope…
Browse files Browse the repository at this point in the history
…rty` (#5292)

Regression by #5290
  • Loading branch information
Dunqing committed Aug 28, 2024
1 parent 5505749 commit 5754c89
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions crates/oxc_transformer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ impl<'a> Traverse<'a> for Transformer<'a> {
self.x0_typescript.transform_property_definition(def);
}

fn enter_accessor_property(
&mut self,
node: &mut AccessorProperty<'a>,
_ctx: &mut TraverseCtx<'a>,
) {
self.x0_typescript.transform_accessor_property(node);
}

fn enter_statements(&mut self, stmts: &mut Vec<'a, Statement<'a>>, ctx: &mut TraverseCtx<'a>) {
self.x0_typescript.transform_statements(stmts);
self.x1_react.transform_statements(stmts, ctx);
Expand Down
6 changes: 6 additions & 0 deletions crates/oxc_transformer/src/typescript/annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ impl<'a> TypeScriptAnnotations<'a> {
def.type_annotation = None;
}

pub fn transform_accessor_property(&mut self, def: &mut AccessorProperty<'a>) {
def.accessibility = None;
def.definite = false;
def.type_annotation = None;
}

pub fn transform_statements(&mut self, stmts: &mut ArenaVec<'a, Statement<'a>>) {
// Remove declare declaration
stmts.retain(
Expand Down
4 changes: 4 additions & 0 deletions crates/oxc_transformer/src/typescript/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ impl<'a> TypeScript<'a> {
self.annotations.transform_property_definition(def);
}

pub fn transform_accessor_property(&mut self, def: &mut AccessorProperty<'a>) {
self.annotations.transform_accessor_property(def);
}

pub fn transform_statements(&mut self, stmts: &mut Vec<'a, Statement<'a>>) {
self.annotations.transform_statements(stmts);
}
Expand Down
3 changes: 0 additions & 3 deletions tasks/coverage/semantic_misc.snap
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,6 @@ tasks/coverage/misc/pass/oxc-5177.ts
semantic error: Bindings mismatch:
after transform: ScopeId(0): ["Bang", "Foo"]
rebuilt : ScopeId(0): ["Bang"]
Unresolved references mismatch:
after transform: []
rebuilt : ["Foo"]

tasks/coverage/misc/pass/swc-7187.ts
semantic error: Bindings mismatch:
Expand Down
2 changes: 0 additions & 2 deletions tasks/transform_conformance/babel.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,6 @@ failed to resolve query: failed to parse the rest of input: ...''


* class/accessor-allowDeclareFields-false/input.ts
x Output mismatch
x TS(18010): An accessibility modifier cannot be used with a private
| identifier.
,-[tasks/coverage/babel/packages/babel-plugin-transform-typescript/test/fixtures/class/accessor-allowDeclareFields-false/input.ts:8:3]
Expand All @@ -1991,7 +1990,6 @@ failed to resolve query: failed to parse the rest of input: ...''


* class/accessor-allowDeclareFields-true/input.ts
x Output mismatch
x TS(18010): An accessibility modifier cannot be used with a private
| identifier.
,-[tasks/coverage/babel/packages/babel-plugin-transform-typescript/test/fixtures/class/accessor-allowDeclareFields-true/input.ts:8:3]
Expand Down

0 comments on commit 5754c89

Please sign in to comment.