Skip to content

Commit

Permalink
fix(isolated_declarations): fix optional class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
escaton committed Jul 2, 2024
1 parent 63c5f1e commit 6edd31a
Show file tree
Hide file tree
Showing 3 changed files with 5 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 @@ -336,7 +336,9 @@ impl<'a> IsolatedDeclarations<'a> {
match element {
ClassElement::StaticBlock(_) => {}
ClassElement::MethodDefinition(ref method) => {
if !method.r#type.is_abstract() && method.value.body.is_none() {
if !(method.r#type.is_abstract() || method.optional)
&& method.value.body.is_none()
{
is_function_overloads = true;
} else if is_function_overloads {
// Skip implementation of function overloads
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_isolated_declarations/tests/fixtures/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class Zoo {

export abstract class Qux {
abstract foo(): void;
protected foo2?(): void;
bar(): void {}
baz(): void {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export declare class Zoo {
}
export declare abstract class Qux {
abstract foo(): void;
protected foo2?(): void;
bar(): void;
baz(): void;
}
Expand Down

0 comments on commit 6edd31a

Please sign in to comment.