fix(isolated-declarations): method following an abstract method gets dropped (#4024)

close: #4019
This commit is contained in:
Dunqing 2024-07-02 13:47:26 +00:00
parent 7844734856
commit 05a047c17d
4 changed files with 19 additions and 2 deletions

View file

@ -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 }

View file

@ -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

View file

@ -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 {}
}

View file

@ -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;
}