fix(transformer/typescript): remove accessibility from AccessorProperty (#5292)

Regression by #5290
This commit is contained in:
Dunqing 2024-08-28 08:42:38 +00:00
parent 550574982f
commit 5754c89b5e
5 changed files with 18 additions and 5 deletions

View file

@ -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);

View file

@ -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(

View file

@ -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);
}

View file

@ -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:

View file

@ -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]
@ -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]