mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
feat(transformer/decorators): insert only one private in expression (#2486)
This commit is contained in:
parent
4c2e2bdf61
commit
cd75c1ca59
2 changed files with 7 additions and 11 deletions
|
|
@ -47,9 +47,6 @@ bitflags! {
|
|||
}
|
||||
|
||||
impl DecoratorFlags {
|
||||
pub fn is_setter(self) -> bool {
|
||||
self.contains(Self::Setter)
|
||||
}
|
||||
pub fn is_static(self) -> bool {
|
||||
self.contains(Self::Static)
|
||||
}
|
||||
|
|
@ -332,7 +329,7 @@ impl<'a> Decorators<'a> {
|
|||
let mut c_elements = self.ast.new_vec();
|
||||
let mut e_elements = self.ast.new_vec();
|
||||
|
||||
let mut private_in_expressions = self.ast.new_vec();
|
||||
let mut private_in_expression = None;
|
||||
|
||||
let mut init_static_name = None;
|
||||
|
||||
|
|
@ -450,9 +447,9 @@ impl<'a> Decorators<'a> {
|
|||
|
||||
if def.key.is_private_identifier() {
|
||||
{
|
||||
if flag.is_setter() && !flag.is_static() {
|
||||
if !flag.is_static() && private_in_expression.is_none() {
|
||||
// _ => #a in _;
|
||||
private_in_expressions.push(
|
||||
private_in_expression = Some(
|
||||
self.ast.arrow_function_expression(
|
||||
SPAN,
|
||||
true,
|
||||
|
|
@ -726,14 +723,14 @@ impl<'a> Decorators<'a> {
|
|||
None,
|
||||
)));
|
||||
arguments.push(class_decorators_argument);
|
||||
if !private_in_expressions.is_empty() {
|
||||
if let Some(private_in_expression) = private_in_expression {
|
||||
// classDecsHaveThis
|
||||
arguments.push(Argument::Expression(self.ast.literal_number_expression(
|
||||
// TODO: use correct number instead of `0`
|
||||
self.ast.number_literal(SPAN, 0f64, "0", oxc_syntax::NumberBase::Decimal),
|
||||
)));
|
||||
// instanceBrand
|
||||
arguments.extend(private_in_expressions.into_iter().map(Argument::Expression));
|
||||
arguments.push(Argument::Expression(private_in_expression));
|
||||
}
|
||||
|
||||
let mut call_expr = self.ast.call_expression(SPAN, callee, arguments, false, None);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Passed: 346/1369
|
||||
Passed: 347/1369
|
||||
|
||||
# All Passed:
|
||||
* babel-plugin-transform-numeric-separator
|
||||
|
|
@ -911,7 +911,7 @@ Passed: 346/1369
|
|||
* spread-transform/transform-to-babel-extend/input.js
|
||||
* spread-transform/transform-to-object-assign/input.js
|
||||
|
||||
# babel-plugin-proposal-decorators (22/190)
|
||||
# babel-plugin-proposal-decorators (23/190)
|
||||
* 2018-09-transformation/async-generator-method/input.js
|
||||
* 2018-09-transformation/class-decorators-yield-await/input.js
|
||||
* 2021-12-accessors/context-name/input.js
|
||||
|
|
@ -1027,7 +1027,6 @@ Passed: 346/1369
|
|||
* 2023-05-fields--to-es2015/static-private/input.js
|
||||
* 2023-05-fields--to-es2015/static-public/input.js
|
||||
* 2023-05-getters/context-name/input.js
|
||||
* 2023-05-getters/private/input.js
|
||||
* 2023-05-getters--to-es2015/context-name/input.js
|
||||
* 2023-05-getters--to-es2015/private/input.js
|
||||
* 2023-05-getters--to-es2015/public/input.js
|
||||
|
|
|
|||
Loading…
Reference in a new issue