Skip to content

Commit

Permalink
fix(isolated-declarations): should print constructor assignments first (
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Sep 21, 2024
1 parent 4e9e838 commit ea32d5b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ impl<'a> IsolatedDeclarations<'a> {
};

if let MethodDefinitionKind::Constructor = method.kind {
elements.extend(
elements.splice(
0..0,
self.transform_constructor_params_to_class_properties(
function, &params,
),
Expand Down
5 changes: 5 additions & 0 deletions crates/oxc_isolated_declarations/tests/fixtures/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ export class Bux {
readonly prop3: number = 1,
) {}
}

export class PrivateFieldsWithConstructorAssignments {
private second = 0;
constructor(public first: number) {}
}
5 changes: 5 additions & 0 deletions crates/oxc_isolated_declarations/tests/snapshots/class.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ export declare class Bux {
readonly prop3: number;
private constructor();
}
export declare class PrivateFieldsWithConstructorAssignments {
first: number;
private second;
constructor(first: number);
}

0 comments on commit ea32d5b

Please sign in to comment.