Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Didn't catch the reference in ExportNamedDeclaration #3795

Closed
mysteryven opened this issue Jun 20, 2024 · 6 comments · Fixed by #3820
Closed

Didn't catch the reference in ExportNamedDeclaration #3795

mysteryven opened this issue Jun 20, 2024 · 6 comments · Fixed by #3820
Assignees
Labels
C-bug Category - Bug

Comments

@mysteryven
Copy link
Member

mysteryven commented Jun 20, 2024

The references of A is empty for:

import { A } from 'foo'

export  { A }

CleanShot 2024-06-20 at 19 39 38@2x

playground

@mysteryven mysteryven added the C-bug Category - Bug label Jun 20, 2024
@Boshen
Copy link
Member

Boshen commented Jun 20, 2024

Related #3796

@Boshen Boshen self-assigned this Jun 20, 2024
@Dunqing
Copy link
Member

Dunqing commented Jun 20, 2024

Related #3796

This is not related tp #3796. C is not the identifier reference. So we cannot catch the reference

@Boshen
Copy link
Member

Boshen commented Jun 21, 2024

It's related, it's not a IdentifierReference, but we need to create a reference for it.

Notice there are 2 references:

image

in binder.ts, it creates a symbol for the name export:

    function bindExportDeclaration(node: ExportDeclaration) {
        if (!container.symbol || !container.symbol.exports) {
            // Export * in some sort of block construct
            bindAnonymousDeclaration(node, SymbolFlags.ExportStar, getDeclarationName(node)!);
        }
        else if (!node.exportClause) {
            // All export * declarations are collected in an __export symbol
            declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.ExportStar, SymbolFlags.None);
        }
        else if (isNamespaceExport(node.exportClause)) {
            // declareSymbol walks up parents to find name text, parent _must_ be set
            // but won't be set by the normal binder walk until `bindChildren` later on.
            setParent(node.exportClause, node);
            declareSymbol(container.symbol.exports, container.symbol, node.exportClause, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
        }
    }

@Boshen
Copy link
Member

Boshen commented Jun 21, 2024

I checked other ASTs, although the spec says it's an IdentiferName, we need to change it to a IdentifierReference

[ModuleExportName](https://tc39.es/ecma262/#prod-ModuleExportName) :
  [IdentifierName](https://tc39.es/ecma262/#prod-IdentifierName)
  [StringLiteral](https://tc39.es/ecma262/#prod-StringLiteral)
pub enum ModuleExportName<'a> {
    Identifier(IdentifierName<'a>), // << change back to identifier reference
    StringLiteral(StringLiteral<'a>),
}

TypeScript definition:

export type ModuleExportName = Identifier | StringLiteral;

@Dunqing
Copy link
Member

Dunqing commented Jun 21, 2024

I'm glad you're considering changing it to IdentifierReference, I totally agree!

@Boshen
Copy link
Member

Boshen commented Jun 22, 2024

I'm working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants