diff --git a/crates/oxc_isolated_declarations/src/signatures.rs b/crates/oxc_isolated_declarations/src/signatures.rs index 54af9ea94..35ffd361b 100644 --- a/crates/oxc_isolated_declarations/src/signatures.rs +++ b/crates/oxc_isolated_declarations/src/signatures.rs @@ -29,12 +29,12 @@ impl<'a> IsolatedDeclarations<'a> { return; }; - let entry = method_annotations.entry(name).or_default(); + let entry = method_annotations.entry(name.clone()).or_default(); entry.0 |= first_param.pattern.type_annotation.is_none(); entry.1 = Some(&mut first_param.pattern.type_annotation); } TSMethodSignatureKind::Get => { - let entry = method_annotations.entry(name).or_default(); + let entry = method_annotations.entry(name.clone()).or_default(); entry.0 |= method.return_type.is_none(); entry.2 = Some(&mut method.return_type); } @@ -43,13 +43,12 @@ impl<'a> IsolatedDeclarations<'a> { }); for (requires_inference, param, return_type) in method_annotations.into_values() { - if !requires_inference { - return; - } - if let (Some(Some(annotation)), Some(option)) | (Some(option), Some(Some(annotation))) = - (param, return_type) - { - option.replace(annotation.clone_in(self.ast.allocator)); + if requires_inference { + if let (Some(Some(annotation)), Some(option)) + | (Some(option), Some(Some(annotation))) = (param, return_type) + { + option.replace(annotation.clone_in(self.ast.allocator)); + } } } } diff --git a/crates/oxc_isolated_declarations/tests/fixtures/signatures.ts b/crates/oxc_isolated_declarations/tests/fixtures/signatures.ts index aa7c76012..0b9a1bc6d 100644 --- a/crates/oxc_isolated_declarations/tests/fixtures/signatures.ts +++ b/crates/oxc_isolated_declarations/tests/fixtures/signatures.ts @@ -17,4 +17,11 @@ export interface I { export interface Ref { get value(): T set value(_: S) +} + +export interface MultipleSetterAndGetter { + get ok(): string + set ok(_: string) + get bad() // infer return type + set bad(_: string) } \ No newline at end of file diff --git a/crates/oxc_isolated_declarations/tests/snapshots/signatures.snap b/crates/oxc_isolated_declarations/tests/snapshots/signatures.snap index 8a3e70ee9..985606a9b 100644 --- a/crates/oxc_isolated_declarations/tests/snapshots/signatures.snap +++ b/crates/oxc_isolated_declarations/tests/snapshots/signatures.snap @@ -31,3 +31,9 @@ export interface Ref< get value(): T; set value(_: S); } +export interface MultipleSetterAndGetter { + get ok(): string; + set ok(_: string); + get bad(): string; + set bad(_: string); +}