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/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ pub enum TSTypePredicateName<'a> {
)]
#[derive(Debug)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut, ContentEq, ESTree)]
#[estree(add_fields(global = TSModuleDeclarationGlobal))]
pub struct TSModuleDeclaration<'a> {
pub span: Span,
/// The name of the module/namespace being declared.
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_ast/src/generated/derive_estree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3009,6 +3009,7 @@ impl ESTree for TSModuleDeclaration<'_> {
state.serialize_field("body", &self.body);
state.serialize_field("kind", &self.kind);
state.serialize_field("declare", &self.declare);
state.serialize_field("global", &crate::serialize::TSModuleDeclarationGlobal(self));
state.end();
}
}
Expand Down
13 changes: 13 additions & 0 deletions crates/oxc_ast/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,19 @@ impl ESTree for ClassImplements<'_, '_> {
}
}

#[ast_meta]
#[estree(
ts_type = "boolean",
raw_deser = "DESER[TSModuleDeclarationKind](POS_OFFSET.kind) === 'global'"
)]
pub struct TSModuleDeclarationGlobal<'a, 'b>(pub &'b TSModuleDeclaration<'a>);

impl ESTree for TSModuleDeclarationGlobal<'_, '_> {
fn serialize<S: Serializer>(&self, serializer: S) {
self.0.kind.is_global().serialize(serializer);
}
}

// --------------------
// JSX
// --------------------
Expand Down
1 change: 1 addition & 0 deletions napi/parser/deserialize-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,7 @@ function deserializeTSModuleDeclaration(pos) {
body: deserializeOptionTSModuleDeclarationBody(pos + 56),
kind: deserializeTSModuleDeclarationKind(pos + 72),
declare: deserializeBool(pos + 73),
global: deserializeTSModuleDeclarationKind(pos + 72) === 'global',
};
}

Expand Down
1 change: 1 addition & 0 deletions napi/parser/deserialize-ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,7 @@ function deserializeTSModuleDeclaration(pos) {
body: deserializeOptionTSModuleDeclarationBody(pos + 56),
kind: deserializeTSModuleDeclarationKind(pos + 72),
declare: deserializeBool(pos + 73),
global: deserializeTSModuleDeclarationKind(pos + 72) === 'global',
};
}

Expand Down
1 change: 1 addition & 0 deletions npm/oxc-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ export interface TSModuleDeclaration extends Span {
body: TSModuleDeclarationBody | null;
kind: TSModuleDeclarationKind;
declare: boolean;
global: boolean;
}

export type TSModuleDeclarationKind = 'global' | 'module' | 'namespace';
Expand Down
120 changes: 1 addition & 119 deletions tasks/coverage/snapshots/estree_typescript.snap

Large diffs are not rendered by default.

Loading