fix(ast): AcessorProperty is missing decorators (#2176)

This commit is contained in:
Dunqing 2024-01-26 15:43:05 +08:00 committed by GitHub
parent 2e3153e16f
commit ea8cc98c34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 4 deletions

View file

@ -2052,6 +2052,7 @@ pub struct AccessorProperty<'a> {
pub value: Option<Expression<'a>>,
pub computed: bool,
pub r#static: bool,
pub decorators: Vec<'a, Decorator<'a>>,
}
#[derive(Debug, Hash)]

View file

@ -886,6 +886,7 @@ impl<'a> AstBuilder<'a> {
value: Option<Expression<'a>>,
computed: bool,
r#static: bool,
decorators: Vec<'a, Decorator<'a>>,
) -> ClassElement<'a> {
ClassElement::AccessorProperty(self.alloc(AccessorProperty {
span,
@ -893,6 +894,7 @@ impl<'a> AstBuilder<'a> {
value,
computed,
r#static,
decorators,
}))
}

View file

@ -478,6 +478,13 @@ impl<'a> Parser<'a> {
) -> Result<ClassElement<'a>> {
let value =
self.eat(Kind::Eq).then(|| self.parse_assignment_expression_base()).transpose()?;
Ok(self.ast.accessor_property(self.end_span(span), key, value, computed, r#static))
Ok(self.ast.accessor_property(
self.end_span(span),
key,
value,
computed,
r#static,
self.state.consume_decorators(),
))
}
}

View file

@ -1,6 +1,6 @@
codegen_typescript Summary:
AST Parsed : 5243/5243 (100.00%)
Positive Passed: 5214/5243 (99.45%)
Positive Passed: 5216/5243 (99.49%)
Expect to Parse: "compiler/binopAssignmentShouldHaveType.ts"
Expect to Parse: "compiler/castExpressionParentheses.ts"
Expect to Parse: "compiler/elidedEmbeddedStatementsReplacedWithSemicolon.ts"
@ -14,8 +14,6 @@ Expect to Parse: "compiler/modularizeLibrary_Dom.asynciterable.ts"
Expect to Parse: "compiler/modularizeLibrary_Worker.asynciterable.ts"
Expect to Parse: "compiler/typeAliasDeclarationEmit3.ts"
Expect to Parse: "conformance/constEnums/constEnum4.ts"
Expect to Parse: "conformance/decorators/legacyDecorators-contextualTypes.ts"
Expect to Parse: "conformance/esDecorators/esDecorators-contextualTypes.ts"
Expect to Parse: "conformance/expressions/asOperator/asOpEmitParens.ts"
Expect to Parse: "conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts"
Expect to Parse: "conformance/jsx/jsxReactTestSuite.tsx"