diff --git a/crates/oxc_isolated_declarations/src/function.rs b/crates/oxc_isolated_declarations/src/function.rs index bb581f3e30aad..e2fe1489ebb03 100644 --- a/crates/oxc_isolated_declarations/src/function.rs +++ b/crates/oxc_isolated_declarations/src/function.rs @@ -48,9 +48,13 @@ impl<'a> IsolatedDeclarations<'a> { is_remaining_params_have_required: bool, ) -> Option> { let pattern = ¶m.pattern; - if pattern.type_annotation.is_none() && pattern.kind.is_destructuring_pattern() { - self.error(parameter_must_have_explicit_type(param.span)); - return None; + if let BindingPatternKind::AssignmentPattern(pattern) = &pattern.kind { + if pattern.left.kind.is_destructuring_pattern() + && pattern.left.type_annotation.is_none() + { + self.error(parameter_must_have_explicit_type(param.span)); + return None; + } } let is_assignment_pattern = pattern.kind.is_assignment_pattern(); diff --git a/crates/oxc_isolated_declarations/tests/snapshots/function-parameters.snap b/crates/oxc_isolated_declarations/tests/snapshots/function-parameters.snap index 1efd93ab35f56..32ff3a31cade8 100644 --- a/crates/oxc_isolated_declarations/tests/snapshots/function-parameters.snap +++ b/crates/oxc_isolated_declarations/tests/snapshots/function-parameters.snap @@ -6,8 +6,8 @@ input_file: crates/oxc_isolated_declarations/tests/fixtures/function-parameters. export declare function fnDeclGood(p?: T, rParam?: string): void; export declare function fnDeclGood2(p?: T, rParam?: number): void; -export declare function fooGood(): number; -export declare const fooGood2: () => number; +export declare function fooGood([a, b]?: any[]): number; +export declare const fooGood2: ({ a, b }?: object) => number; export declare function fnDeclBad(p: T, rParam: T, r2: T): void; export declare function fnDeclBad2(p: T, r2: T): void; export declare function fnDeclBad3(p: T, rParam?: T, r2: T): void; @@ -17,24 +17,6 @@ export declare const fooBad2: () => number; ==================== Errors ==================== - x TS9011: Parameter must have an explicit type annotation with - | --isolatedDeclarations. - ,-[5:25] - 4 | - 5 | export function fooGood([a, b]: any[] = [1, 2]): number { - : ^^^^^^^^^^^^^^^^^^^^^^ - 6 | return 2; - `---- - - x TS9011: Parameter must have an explicit type annotation with - | --isolatedDeclarations. - ,-[9:26] - 8 | - 9 | export const fooGood2 = ({a, b}: object = { a: 1, b: 2 }): number => { - : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 10 | return 2; - `---- - x TS9025: Declaration emit for this parameter requires implicitly adding | undefined to it's type. This is not supported with --isolatedDeclarations. ,-[14:30]