Skip to content

Commit

Permalink
fix(isolated-declarations): private constructor reaching unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Jun 26, 2024
1 parent e35472f commit 611b506
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 1 addition & 4 deletions crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'a> IsolatedDeclarations<'a> {
self.transform_accessibility(method.accessibility),
)
}
MethodDefinitionKind::Get => {
MethodDefinitionKind::Get | MethodDefinitionKind::Constructor => {
let params = self.ast.formal_parameters(
SPAN,
FormalParameterKind::Signature,
Expand All @@ -221,9 +221,6 @@ impl<'a> IsolatedDeclarations<'a> {
);
self.transform_class_method_definition(method, params, None)
}
MethodDefinitionKind::Constructor => {
unreachable!()
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions crates/oxc_isolated_declarations/tests/fixtures/class.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class Foo {
private constructor(a: number = 0) {}
}

export class Bar {
public constructor(a: number = 0) {}
}
12 changes: 12 additions & 0 deletions crates/oxc_isolated_declarations/tests/snapshots/class.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/class.ts
---
==================== .D.TS ====================

export declare class Foo {
private constructor();
}
export declare class Bar {
constructor(a?: number);
}

0 comments on commit 611b506

Please sign in to comment.