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

Store References for TS identifers separately in Semantic #36

Open
overlookmotel opened this issue Jun 6, 2024 · 1 comment
Open

Store References for TS identifers separately in Semantic #36

overlookmotel opened this issue Jun 6, 2024 · 1 comment

Comments

@overlookmotel
Copy link

Boshen's idea from today's meeting:

Store references used in TS IdentiferReferences separately from normal references:

pub struct SymbolTable {
    pub resolved_references: IndexVec<SymbolId, Vec<ReferenceId>>,
    pub resolved_ts_references: IndexVec<SymbolId, Vec<ReferenceId>>,
    /* ... more ... */
}

Advantage is that when transforming TS to JS, you can just clear resolved_ts_references (or ignore it) when calculating if a symbol is referenced or not.

Symbols would be stored together regardless of whether they're types or not to allow for when a symbol is used in both contexts e.g.:

import Foo from 'foo';
let foo = new Foo(); // JS usage
function bar(foo: Foo) {} // TS usage

Maybe use a different AST type TSIdentiferReference for identifiers in TS contexts, to simplify visitors.

See also the point "Get rid of Reference" in #32.

@overlookmotel overlookmotel changed the title Store References for TS IdentiferReferences separately Store References for TS IdentiferReferences separately in Semantic Jun 6, 2024
@overlookmotel overlookmotel changed the title Store References for TS IdentiferReferences separately in Semantic Store References for TS identifers separately in Semantic Jun 6, 2024
@overlookmotel
Copy link
Author

oxc-project/oxc#3799 is relevant. Possible we don't want to resolve TS identifier references at all.

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

No branches or pull requests

1 participant