Skip to content

Commit

Permalink
fix: fix extends BindingPattern in d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Feb 8, 2025
1 parent a601a15 commit 8545cac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,12 @@ export interface CatchClause extends Span {
body: BlockStatement;
}

export interface CatchParameter extends Span, BindingPattern {
type: 'CatchParameter';
}
export type CatchParameter =
& ({
type: 'CatchParameter';
})
& Span
& BindingPattern;

export interface DebuggerStatement extends Span {
type: 'DebuggerStatement';
Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/generators/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ fn generate_ts_type_def_for_struct_field<'s>(
}
}

if field_type_name.contains('|') {
// need `type` instead of `interface` when flattening BindingPattern
if field_type_name.contains('|') || field_type_name == "BindingPattern" {
*output_as_type = true;
}
extends.push(field_type_name);
Expand Down

0 comments on commit 8545cac

Please sign in to comment.