Skip to content

Commit 78500af

Browse files
authoredOct 25, 2024··
fix(typescript): Check whether the method is abstract when checking is_overload (#9678)
**Related issue:** - Closes #9656
1 parent b8d255b commit 78500af

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed
 

‎.changeset/fair-maps-move.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc_typescript: patch
4+
---
5+
6+
fix(typescript): Check whether the method is abstract when checking `is_overload`

‎crates/swc_typescript/src/fast_dts/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ impl FastDts {
758758
}
759759
}
760760
ClassMember::Method(method) => {
761-
let is_overload = method.function.body.is_none();
761+
let is_overload = method.function.body.is_none() && !method.is_abstract;
762762
if !prev_is_overload || is_overload {
763763
prev_is_overload = is_overload;
764764
true

‎crates/swc_typescript/tests/fast_dts_deno.rs

+20
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,26 @@ fn dts_class_decl_prop_infer_test() {
218218
);
219219
}
220220

221+
#[test]
222+
fn dts_class_abstract_method_test() {
223+
transform_dts_test(
224+
r#"export abstract class Manager {
225+
protected abstract A(): void;
226+
protected B(): void {
227+
console.log("B");
228+
}
229+
protected C(): void {
230+
console.log("B");
231+
}
232+
}"#,
233+
r#"export declare abstract class Manager {
234+
protected abstract A(): void;
235+
protected B(): void;
236+
protected C(): void;
237+
}"#,
238+
);
239+
}
240+
221241
#[test]
222242
fn dts_var_decl_test() {
223243
transform_dts_test(

0 commit comments

Comments
 (0)
Please sign in to comment.