Skip to content

Commit 4f1343b

Browse files
ulrichstarkBoshen
andauthored
fix(parser): fix missing type export in module information (#10516)
Closes #10505 --------- Co-authored-by: Boshen <[email protected]>
1 parent 5ba02b0 commit 4f1343b

File tree

11 files changed

+116
-39
lines changed

11 files changed

+116
-39
lines changed

crates/oxc_parser/src/module_record.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,8 @@ impl<'a> ModuleRecordBuilder<'a> {
317317
}
318318

319319
fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration<'a>) {
320-
if decl.export_kind.is_type() {
321-
return;
322-
}
323320
// ignore all TypeScript syntax as they overload
324-
if decl.is_typescript_syntax() {
321+
if decl.declaration.as_ref().is_some_and(Declaration::is_typescript_syntax) {
325322
return;
326323
}
327324

crates/oxc_syntax/src/generated/derive_estree.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ impl ESTree for ExportEntry<'_> {
5252
state.serialize_field("importName", &self.import_name);
5353
state.serialize_field("exportName", &self.export_name);
5454
state.serialize_field("localName", &self.local_name);
55+
state.serialize_field("isType", &self.is_type);
5556
state.end();
5657
}
5758
}

crates/oxc_syntax/src/module_record.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ pub struct ExportEntry<'a> {
270270
/// export { type foo }
271271
/// export type { foo } from 'mod'
272272
/// ```
273-
#[estree(skip)]
274273
pub is_type: bool,
275274
}
276275

napi/parser/deserialize-js.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,7 @@ function deserializeExportEntry(pos) {
20392039
importName: deserializeExportImportName(pos + 40),
20402040
exportName: deserializeExportExportName(pos + 72),
20412041
localName: deserializeExportLocalName(pos + 104),
2042+
isType: deserializeBool(pos + 136),
20422043
};
20432044
}
20442045

napi/parser/deserialize-ts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,7 @@ function deserializeExportEntry(pos) {
21662166
importName: deserializeExportImportName(pos + 40),
21672167
exportName: deserializeExportExportName(pos + 72),
21682168
localName: deserializeExportLocalName(pos + 104),
2169+
isType: deserializeBool(pos + 136),
21692170
};
21702171
}
21712172

napi/parser/index.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ export interface StaticExportEntry {
232232
exportName: ExportExportName
233233
/** The name that is used to locally access the exported value from within the importing module. */
234234
localName: ExportLocalName
235+
/**
236+
* Whether the export is a TypeScript `export type`.
237+
*
238+
* Examples:
239+
*
240+
* ```ts
241+
* export type * from 'mod';
242+
* export type * as ns from 'mod';
243+
* export type { foo };
244+
* export { type foo }:
245+
* export type { foo } from 'mod';
246+
* ```
247+
*/
248+
isType: boolean
235249
}
236250

237251
export interface StaticImport {

napi/parser/src/convert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl From<&module_record::ExportEntry<'_>> for StaticExportEntry {
9292
import_name: ExportImportName::from(&e.import_name),
9393
export_name: ExportExportName::from(&e.export_name),
9494
local_name: ExportLocalName::from(&e.local_name),
95+
is_type: e.is_type,
9596
}
9697
}
9798
}

napi/parser/src/types.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ pub struct StaticExportEntry {
180180
pub export_name: ExportExportName,
181181
/// The name that is used to locally access the exported value from within the importing module.
182182
pub local_name: ExportLocalName,
183+
/// Whether the export is a TypeScript `export type`.
184+
///
185+
/// Examples:
186+
///
187+
/// ```ts
188+
/// export type * from 'mod';
189+
/// export type * as ns from 'mod';
190+
/// export type { foo };
191+
/// export { type foo }:
192+
/// export type { foo } from 'mod';
193+
/// ```
194+
pub is_type: bool,
183195
}
184196

185197
#[napi(object)]

0 commit comments

Comments
 (0)