Skip to content

Commit

Permalink
fix(isolated-declarations): missing print comments in class's private…
Browse files Browse the repository at this point in the history
… method (#5931)
  • Loading branch information
Dunqing committed Sep 20, 2024
1 parent 8780c54 commit 0f96b59
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ impl<'a> IsolatedDeclarations<'a> {
fn create_class_property(
&self,
r#type: PropertyDefinitionType,
span: Span,
key: PropertyKey<'a>,
r#static: bool,
r#override: bool,
accessibility: Option<TSAccessibility>,
) -> ClassElement<'a> {
self.ast.class_element_property_definition(
r#type,
SPAN,
span,
self.ast.vec(),
key,
None,
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions crates/oxc_isolated_declarations/tests/fixtures/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}

Expand Down
18 changes: 18 additions & 0 deletions crates/oxc_isolated_declarations/tests/snapshots/class.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0f96b59

Please sign in to comment.