feat(semantic): add export binding for ExportDefaultDeclarations in module record (#2329)

This commit is contained in:
Dunqing 2024-02-06 22:01:16 +08:00 committed by GitHub
parent 3b7dfb9bd1
commit 40e9541cec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -247,7 +247,9 @@ fn test() {
let fail = vec![
(r#"let foo; export { foo }; export * from "./export-all""#),
// (r#"export * from "./malformed.js""#),
(r#"export * from "./default-export""#),
// This case has been comment out in eslint-plugin-import
// https://github.com/import-js/eslint-plugin-import/blob/7a21f7e10f18c04473faadca94928af6b8e28009/tests/src/rules/export.js#L101-L109
// (r#"export * from "./default-export""#),
(r#"let foo; export { foo as "foo" }; export * from "./export-all""#),
("
export type Foo = string;

View file

@ -291,6 +291,9 @@ impl ModuleRecordBuilder {
..ExportEntry::default()
};
self.add_export_entry(export_entry);
if let Some(id) = id {
self.add_export_binding(id.name.clone(), id.span);
}
}
fn visit_export_named_declaration(&mut self, decl: &ExportNamedDeclaration) {

View file

@ -5,7 +5,14 @@ pub use util::SemanticTester;
#[test]
fn test_class_simple() {
SemanticTester::js("export class Foo {}")
SemanticTester::js("export class Foo {};")
.has_root_symbol("Foo")
.contains_flags(SymbolFlags::Class | SymbolFlags::Export)
.has_number_of_references(0)
.is_exported()
.test();
SemanticTester::js("export default class Foo {};")
.has_root_symbol("Foo")
.contains_flags(SymbolFlags::Class | SymbolFlags::Export)
.has_number_of_references(0)