fix(typescript): Check whether the method is abstract when checking is_overload (#9678)
Some checks failed
CI / Cargo fmt (push) Has been cancelled
CI / Cargo clippy (push) Has been cancelled
CI / Check license of dependencies (push) Has been cancelled
CI / Check (macos-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / Test wasm (binding_core_wasm) (push) Has been cancelled
CI / Test wasm (binding_minifier_wasm) (push) Has been cancelled
CI / Test wasm (binding_typescript_wasm) (push) Has been cancelled
CI / List crates (push) Has been cancelled
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Has been cancelled
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Has been cancelled
CI / Test with @swc/cli (push) Has been cancelled
CI / Miri (better_scoped_tls) (push) Has been cancelled
CI / Miri (string_enum) (push) Has been cancelled
CI / Miri (swc) (push) Has been cancelled
CI / Miri (swc_bundler) (push) Has been cancelled
Benchmark / Bench everything (push) Has been cancelled
Publish crates (auto) / Publish cargo crates (push) Has been cancelled
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Has been cancelled
CI / Done (push) Has been cancelled

**Related issue:**

 - Closes https://github.com/swc-project/swc/issues/9656
This commit is contained in:
CPunisher 2024-10-25 11:53:48 +08:00 committed by GitHub
parent b8d255bf5a
commit 78500af546
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,6 @@
---
swc_core: patch
swc_typescript: patch
---
fix(typescript): Check whether the method is abstract when checking `is_overload`

View File

@ -758,7 +758,7 @@ impl FastDts {
} }
} }
ClassMember::Method(method) => { ClassMember::Method(method) => {
let is_overload = method.function.body.is_none(); let is_overload = method.function.body.is_none() && !method.is_abstract;
if !prev_is_overload || is_overload { if !prev_is_overload || is_overload {
prev_is_overload = is_overload; prev_is_overload = is_overload;
true true

View File

@ -218,6 +218,26 @@ fn dts_class_decl_prop_infer_test() {
); );
} }
#[test]
fn dts_class_abstract_method_test() {
transform_dts_test(
r#"export abstract class Manager {
protected abstract A(): void;
protected B(): void {
console.log("B");
}
protected C(): void {
console.log("B");
}
}"#,
r#"export declare abstract class Manager {
protected abstract A(): void;
protected B(): void;
protected C(): void;
}"#,
);
}
#[test] #[test]
fn dts_var_decl_test() { fn dts_var_decl_test() {
transform_dts_test( transform_dts_test(