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
5 changes: 4 additions & 1 deletion crates/oxc_ast/src/ast/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ pub struct IdentifierReference<'a> {
#[ast(visit)]
#[derive(Debug, Clone)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(rename = "Identifier")]
#[estree(
rename = "Identifier",
add_fields(decorators = TsEmptyArray, optional = TsFalse, typeAnnotation = TsNull)
)]
pub struct BindingIdentifier<'a> {
pub span: Span,
/// The identifier name being bound.
Expand Down
3 changes: 3 additions & 0 deletions crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ impl ESTree for BindingIdentifier<'_> {
state.serialize_field("start", &self.span.start);
state.serialize_field("end", &self.span.end);
state.serialize_field("name", &JsonSafeString(self.name.as_str()));
state.serialize_ts_field("decorators", &crate::serialize::TsEmptyArray(self));
state.serialize_ts_field("optional", &crate::serialize::TsFalse(self));
state.serialize_ts_field("typeAnnotation", &crate::serialize::TsNull(self));
state.end();
}
}
Expand Down
3 changes: 3 additions & 0 deletions napi/parser/deserialize-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ function deserializeBindingIdentifier(pos) {
start: deserializeU32(pos),
end: deserializeU32(pos + 4),
name: deserializeStr(pos + 8),
decorators: [],
optional: false,
typeAnnotation: null,
};
}

Expand Down
1 change: 1 addition & 0 deletions napi/parser/test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ describe('parse', () => {
start: 4,
end: 5,
name: 'x',
decorators: [],
typeAnnotation: null,
optional: false,
},
Expand Down
3 changes: 3 additions & 0 deletions npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export interface IdentifierReference extends Span {
export interface BindingIdentifier extends Span {
type: 'Identifier';
name: string;
decorators?: [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this types be generated as non optional?

optional?: false;
typeAnnotation?: null;
}

export interface LabelIdentifier extends Span {
Expand Down
Loading