Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,7 @@ pub struct CatchClause<'a> {
pub struct CatchParameter<'a> {
pub span: Span,
/// The bound error
#[estree(flatten)]
pub pattern: BindingPattern<'a>,
}

Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,9 @@ impl Serialize for CatchParameter<'_> {
map.serialize_entry("type", "CatchParameter")?;
map.serialize_entry("start", &self.span.start)?;
map.serialize_entry("end", &self.span.end)?;
map.serialize_entry("pattern", &self.pattern)?;
self.pattern.kind.serialize(FlatMapSerializer(&mut map))?;
map.serialize_entry("typeAnnotation", &self.pattern.type_annotation)?;
map.serialize_entry("optional", &self.pattern.optional)?;
map.end()
}
}
Expand Down
10 changes: 6 additions & 4 deletions npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,12 @@ export interface CatchClause extends Span {
body: BlockStatement;
}

export interface CatchParameter extends Span {
type: 'CatchParameter';
pattern: BindingPattern;
}
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 @@ -220,7 +220,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
Loading
Loading