Skip to content
Merged
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
5 changes: 4 additions & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2300,7 +2300,7 @@ pub enum AccessorPropertyType {
#[generate_derive(CloneIn, Dummy, TakeIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[rustfmt::skip]
#[estree(
add_fields(declare = TsFalse, optional = TsFalse, r#override = TsFalse, readonly = TsFalse),
add_fields(declare = TsFalse, optional = TsFalse, readonly = TsFalse),
field_order(
r#type, span, key, value, computed, r#static, decorators, definite, type_annotation,
accessibility, optional, r#override, readonly, declare)
Expand All @@ -2321,6 +2321,9 @@ pub struct AccessorProperty<'a> {
pub computed: bool,
/// Property was declared with a `static` modifier
pub r#static: bool,
/// Property was declared with a `override` modifier
#[ts]
pub r#override: bool,
/// Property has a `!` after its key.
#[ts]
pub definite: bool,
Expand Down
6 changes: 4 additions & 2 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,8 @@ const _: () = {
assert!(offset_of!(AccessorProperty, value) == 64);
assert!(offset_of!(AccessorProperty, computed) == 80);
assert!(offset_of!(AccessorProperty, r#static) == 81);
assert!(offset_of!(AccessorProperty, definite) == 82);
assert!(offset_of!(AccessorProperty, r#override) == 82);
assert!(offset_of!(AccessorProperty, definite) == 83);
assert!(offset_of!(AccessorProperty, type_annotation) == 88);
assert!(offset_of!(AccessorProperty, accessibility) == 96);

Expand Down Expand Up @@ -2051,7 +2052,8 @@ const _: () = {
assert!(offset_of!(AccessorProperty, value) == 36);
assert!(offset_of!(AccessorProperty, computed) == 44);
assert!(offset_of!(AccessorProperty, r#static) == 45);
assert!(offset_of!(AccessorProperty, definite) == 46);
assert!(offset_of!(AccessorProperty, r#override) == 46);
assert!(offset_of!(AccessorProperty, definite) == 47);
assert!(offset_of!(AccessorProperty, type_annotation) == 48);
assert!(offset_of!(AccessorProperty, accessibility) == 52);

Expand Down
9 changes: 9 additions & 0 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6693,6 +6693,7 @@ impl<'a> AstBuilder<'a> {
/// * `value`: Initialized value in the declaration, if present.
/// * `computed`: Property was declared with a computed key
/// * `static`: Property was declared with a `static` modifier
/// * `override`: Property was declared with a `override` modifier
/// * `definite`: Property has a `!` after its key.
/// * `type_annotation`: Type annotation on the property.
/// * `accessibility`: Accessibility modifier.
Expand All @@ -6706,6 +6707,7 @@ impl<'a> AstBuilder<'a> {
value: Option<Expression<'a>>,
computed: bool,
r#static: bool,
r#override: bool,
definite: bool,
type_annotation: T1,
accessibility: Option<TSAccessibility>,
Expand All @@ -6721,6 +6723,7 @@ impl<'a> AstBuilder<'a> {
value,
computed,
r#static,
r#override,
definite,
type_annotation,
accessibility,
Expand Down Expand Up @@ -7250,6 +7253,7 @@ impl<'a> AstBuilder<'a> {
/// * `value`: Initialized value in the declaration, if present.
/// * `computed`: Property was declared with a computed key
/// * `static`: Property was declared with a `static` modifier
/// * `override`: Property was declared with a `override` modifier
/// * `definite`: Property has a `!` after its key.
/// * `type_annotation`: Type annotation on the property.
/// * `accessibility`: Accessibility modifier.
Expand All @@ -7263,6 +7267,7 @@ impl<'a> AstBuilder<'a> {
value: Option<Expression<'a>>,
computed: bool,
r#static: bool,
r#override: bool,
definite: bool,
type_annotation: T1,
accessibility: Option<TSAccessibility>,
Expand All @@ -7278,6 +7283,7 @@ impl<'a> AstBuilder<'a> {
value,
computed,
r#static,
r#override,
definite,
type_annotation: type_annotation.into_in(self.allocator),
accessibility,
Expand All @@ -7297,6 +7303,7 @@ impl<'a> AstBuilder<'a> {
/// * `value`: Initialized value in the declaration, if present.
/// * `computed`: Property was declared with a computed key
/// * `static`: Property was declared with a `static` modifier
/// * `override`: Property was declared with a `override` modifier
/// * `definite`: Property has a `!` after its key.
/// * `type_annotation`: Type annotation on the property.
/// * `accessibility`: Accessibility modifier.
Expand All @@ -7310,6 +7317,7 @@ impl<'a> AstBuilder<'a> {
value: Option<Expression<'a>>,
computed: bool,
r#static: bool,
r#override: bool,
definite: bool,
type_annotation: T1,
accessibility: Option<TSAccessibility>,
Expand All @@ -7326,6 +7334,7 @@ impl<'a> AstBuilder<'a> {
value,
computed,
r#static,
r#override,
definite,
type_annotation,
accessibility,
Expand Down
2 changes: 2 additions & 0 deletions crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4072,6 +4072,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for AccessorProperty<'_> {
value: CloneIn::clone_in(&self.value, allocator),
computed: CloneIn::clone_in(&self.computed, allocator),
r#static: CloneIn::clone_in(&self.r#static, allocator),
r#override: CloneIn::clone_in(&self.r#override, allocator),
definite: CloneIn::clone_in(&self.definite, allocator),
type_annotation: CloneIn::clone_in(&self.type_annotation, allocator),
accessibility: CloneIn::clone_in(&self.accessibility, allocator),
Expand All @@ -4087,6 +4088,7 @@ impl<'new_alloc> CloneIn<'new_alloc> for AccessorProperty<'_> {
value: CloneIn::clone_in_with_semantic_ids(&self.value, allocator),
computed: CloneIn::clone_in_with_semantic_ids(&self.computed, allocator),
r#static: CloneIn::clone_in_with_semantic_ids(&self.r#static, allocator),
r#override: CloneIn::clone_in_with_semantic_ids(&self.r#override, allocator),
definite: CloneIn::clone_in_with_semantic_ids(&self.definite, allocator),
type_annotation: CloneIn::clone_in_with_semantic_ids(&self.type_annotation, allocator),
accessibility: CloneIn::clone_in_with_semantic_ids(&self.accessibility, allocator),
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1252,6 +1252,7 @@ impl ContentEq for AccessorProperty<'_> {
&& ContentEq::content_eq(&self.value, &other.value)
&& ContentEq::content_eq(&self.computed, &other.computed)
&& ContentEq::content_eq(&self.r#static, &other.r#static)
&& ContentEq::content_eq(&self.r#override, &other.r#override)
&& ContentEq::content_eq(&self.definite, &other.definite)
&& ContentEq::content_eq(&self.type_annotation, &other.type_annotation)
&& ContentEq::content_eq(&self.accessibility, &other.accessibility)
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_ast/src/generated/derive_dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,7 @@ impl<'a> Dummy<'a> for AccessorProperty<'a> {
value: Dummy::dummy(allocator),
computed: Dummy::dummy(allocator),
r#static: Dummy::dummy(allocator),
r#override: Dummy::dummy(allocator),
definite: Dummy::dummy(allocator),
type_annotation: Dummy::dummy(allocator),
accessibility: Dummy::dummy(allocator),
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ impl ESTree for AccessorProperty<'_> {
state.serialize_ts_field("typeAnnotation", &self.type_annotation);
state.serialize_ts_field("accessibility", &self.accessibility);
state.serialize_ts_field("optional", &crate::serialize::TsFalse(self));
state.serialize_ts_field("override", &crate::serialize::TsFalse(self));
state.serialize_ts_field("override", &self.r#override);
state.serialize_ts_field("readonly", &crate::serialize::TsFalse(self));
state.serialize_ts_field("declare", &crate::serialize::TsFalse(self));
state.end();
Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2782,6 +2782,11 @@ impl Gen for AccessorProperty<'_> {
p.print_str("static");
p.print_soft_space();
}
if self.r#override {
p.print_space_before_identifier();
p.print_str("override");
p.print_soft_space();
}
p.print_space_before_identifier();
p.print_str("accessor");
if self.computed {
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ impl<'a> IsolatedDeclarations<'a> {
None,
property.computed,
property.r#static,
property.r#override,
property.definite,
type_annotation,
property.accessibility,
Expand Down
3 changes: 3 additions & 0 deletions crates/oxc_parser/src/js/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ impl<'a> ParserImpl<'a> {
computed,
r#static,
r#abstract,
r#override,
definite,
accessibility,
)
Expand Down Expand Up @@ -498,6 +499,7 @@ impl<'a> ParserImpl<'a> {
computed: bool,
r#static: bool,
r#abstract: bool,
r#override: bool,
definite: bool,
accessibility: Option<TSAccessibility>,
) -> Result<ClassElement<'a>> {
Expand All @@ -519,6 +521,7 @@ impl<'a> ParserImpl<'a> {
value,
computed,
r#static,
r#override,
definite,
type_annotation,
accessibility,
Expand Down
22 changes: 22 additions & 0 deletions crates/oxc_traverse/src/generated/ancestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9042,6 +9042,8 @@ pub(crate) const OFFSET_ACCESSOR_PROPERTY_KEY: usize = offset_of!(AccessorProper
pub(crate) const OFFSET_ACCESSOR_PROPERTY_VALUE: usize = offset_of!(AccessorProperty, value);
pub(crate) const OFFSET_ACCESSOR_PROPERTY_COMPUTED: usize = offset_of!(AccessorProperty, computed);
pub(crate) const OFFSET_ACCESSOR_PROPERTY_STATIC: usize = offset_of!(AccessorProperty, r#static);
pub(crate) const OFFSET_ACCESSOR_PROPERTY_OVERRIDE: usize =
offset_of!(AccessorProperty, r#override);
pub(crate) const OFFSET_ACCESSOR_PROPERTY_DEFINITE: usize = offset_of!(AccessorProperty, definite);
pub(crate) const OFFSET_ACCESSOR_PROPERTY_TYPE_ANNOTATION: usize =
offset_of!(AccessorProperty, type_annotation);
Expand Down Expand Up @@ -9094,6 +9096,11 @@ impl<'a, 't> AccessorPropertyWithoutDecorators<'a, 't> {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
}

#[inline]
pub fn r#override(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_OVERRIDE) as *const bool) }
}

#[inline]
pub fn definite(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DEFINITE) as *const bool) }
Expand Down Expand Up @@ -9170,6 +9177,11 @@ impl<'a, 't> AccessorPropertyWithoutKey<'a, 't> {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
}

#[inline]
pub fn r#override(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_OVERRIDE) as *const bool) }
}

#[inline]
pub fn definite(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DEFINITE) as *const bool) }
Expand Down Expand Up @@ -9245,6 +9257,11 @@ impl<'a, 't> AccessorPropertyWithoutValue<'a, 't> {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
}

#[inline]
pub fn r#override(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_OVERRIDE) as *const bool) }
}

#[inline]
pub fn definite(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DEFINITE) as *const bool) }
Expand Down Expand Up @@ -9328,6 +9345,11 @@ impl<'a, 't> AccessorPropertyWithoutTypeAnnotation<'a, 't> {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
}

#[inline]
pub fn r#override(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_OVERRIDE) as *const bool) }
}

#[inline]
pub fn definite(self) -> &'t bool {
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DEFINITE) as *const bool) }
Expand Down
4 changes: 2 additions & 2 deletions napi/parser/deserialize-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,11 +969,11 @@ function deserializeAccessorProperty(pos) {
computed: deserializeBool(pos + 80),
static: deserializeBool(pos + 81),
decorators: deserializeVecDecorator(pos + 16),
definite: deserializeBool(pos + 82),
definite: deserializeBool(pos + 83),
typeAnnotation: deserializeOptionBoxTSTypeAnnotation(pos + 88),
accessibility: deserializeOptionTSAccessibility(pos + 96),
optional: false,
override: false,
override: deserializeBool(pos + 82),
readonly: false,
declare: false,
};
Expand Down
2 changes: 1 addition & 1 deletion npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ export interface AccessorProperty extends Span {
typeAnnotation?: TSTypeAnnotation | null;
accessibility?: TSAccessibility | null;
optional?: false;
override?: false;
override?: boolean;
readonly?: false;
declare?: false;
}
Expand Down
3 changes: 1 addition & 2 deletions tasks/coverage/snapshots/estree_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: 15392346

estree_typescript Summary:
AST Parsed : 10619/10725 (99.01%)
Positive Passed: 8914/10725 (83.11%)
Positive Passed: 8915/10725 (83.12%)
Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts
A class member cannot have the 'const' keyword.
Mismatch: tasks/coverage/typescript/tests/cases/compiler/abstractPropertyInConstructor.ts
Expand Down Expand Up @@ -1128,7 +1128,6 @@ Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/mixinClasses
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/mixinClassesAnonymous.ts
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationES2022.ts
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/assignParameterPropertyToPropertyDeclarationESNext.ts
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/autoAccessorAllowedModifiers.ts
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/defineProperty.ts
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/initializationOrdering1.ts
Mismatch: tasks/coverage/typescript/tests/cases/conformance/classes/propertyMemberDeclarations/initializerReferencingConstructorLocals.ts
Expand Down
Loading