Skip to content

Commit

Permalink
fix(isolated-declarations): method following an abstract method gets …
Browse files Browse the repository at this point in the history
…dropped (#4024)

close: #4019
  • Loading branch information
Dunqing committed Jul 2, 2024
1 parent 7844734 commit 05a047c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,12 @@ impl MethodDefinitionKind {
}
}

impl MethodDefinitionType {
pub fn is_abstract(&self) -> bool {
matches!(self, Self::TSAbstractMethodDefinition)
}
}

impl<'a> PrivateIdentifier<'a> {
pub fn new(span: Span, name: Atom<'a>) -> Self {
Self { span, name }
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_isolated_declarations/src/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl<'a> IsolatedDeclarations<'a> {
match element {
ClassElement::StaticBlock(_) => {}
ClassElement::MethodDefinition(ref method) => {
if method.value.body.is_none() {
if !method.r#type.is_abstract() && method.value.body.is_none() {
is_function_overloads = true;
} else if is_function_overloads {
// Skip implementation of function overloads
Expand Down
8 changes: 7 additions & 1 deletion crates/oxc_isolated_declarations/tests/fixtures/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ export class Bar {
public constructor(a: number = 0) {}
}

export class Zoo { foo<F>(f: F): F { return f } }
export class Zoo { foo<F>(f: F): F { return f } }

export abstract class Qux {
abstract foo(): void;
bar(): void {}
baz(): void {}
}
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 @@ -13,3 +13,8 @@ export declare class Bar {
export declare class Zoo {
foo<F>(f: F): F;
}
export declare abstract class Qux {
abstract foo(): void;
bar(): void;
baz(): void;
}

0 comments on commit 05a047c

Please sign in to comment.