diff --git a/crates/oxc_isolated_declarations/src/class.rs b/crates/oxc_isolated_declarations/src/class.rs index a1b70d82dd695..5523dfc1f71dc 100644 --- a/crates/oxc_isolated_declarations/src/class.rs +++ b/crates/oxc_isolated_declarations/src/class.rs @@ -152,6 +152,7 @@ impl<'a> IsolatedDeclarations<'a> { fn create_class_property( &self, r#type: PropertyDefinitionType, + span: Span, key: PropertyKey<'a>, r#static: bool, r#override: bool, @@ -159,7 +160,7 @@ impl<'a> IsolatedDeclarations<'a> { ) -> ClassElement<'a> { self.ast.class_element_property_definition( r#type, - SPAN, + span, self.ast.vec(), key, None, @@ -216,6 +217,7 @@ impl<'a> IsolatedDeclarations<'a> { }; self.create_class_property( r#type, + method.span, // SAFETY: `ast.copy` is unsound! We need to fix. unsafe { self.ast.copy(&method.key) }, method.r#static, diff --git a/crates/oxc_isolated_declarations/tests/fixtures/class.ts b/crates/oxc_isolated_declarations/tests/fixtures/class.ts index 8d57b0508bc28..6b97c624999ca 100644 --- a/crates/oxc_isolated_declarations/tests/fixtures/class.ts +++ b/crates/oxc_isolated_declarations/tests/fixtures/class.ts @@ -20,11 +20,29 @@ export abstract class Qux { } export class Baz { + /** + * Just a comment + */ readonly prop1 = 'some string'; + /** + * Just a comment + */ prop2 = 'another string'; + /** + * Just a comment + */ private prop3 = 'yet another string'; + /** + * Just a comment + */ private prop4(): void {} + /** + * Just a comment + */ private static prop5 = 'yet another string'; + /** + * Just a comment + */ private static prop6(): void {} } diff --git a/crates/oxc_isolated_declarations/tests/snapshots/class.snap b/crates/oxc_isolated_declarations/tests/snapshots/class.snap index a6b5b4505986d..5d6f96686b8fd 100644 --- a/crates/oxc_isolated_declarations/tests/snapshots/class.snap +++ b/crates/oxc_isolated_declarations/tests/snapshots/class.snap @@ -20,11 +20,29 @@ export declare abstract class Qux { baz(): void; } export declare class Baz { + /** + * Just a comment + */ readonly prop1 = "some string"; + /** + * Just a comment + */ prop2: string; + /** + * Just a comment + */ private prop3; + /** + * Just a comment + */ private prop4; + /** + * Just a comment + */ private static prop5; + /** + * Just a comment + */ private static prop6; } export declare class Boo {