mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
fix(isolated-declarations): infer failed if there are two setter/getter methods that need to be inferred (#5967)
This commit is contained in:
parent
c84bd28a9c
commit
fd1c46ca9e
3 changed files with 21 additions and 9 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,4 +17,11 @@ export interface I {
|
|||
export interface Ref<T = any, S = T> {
|
||||
get value(): T
|
||||
set value(_: S)
|
||||
}
|
||||
|
||||
export interface MultipleSetterAndGetter {
|
||||
get ok(): string
|
||||
set ok(_: string)
|
||||
get bad() // infer return type
|
||||
set bad(_: string)
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue