Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(isolated-declarations): private constructor reaching unreachable #3921

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: 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);
}
Loading