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

Ideas for AST changes #9161

Open
kdy1 opened this issue Jul 6, 2024 · 11 comments
Open

Ideas for AST changes #9161

kdy1 opened this issue Jul 6, 2024 · 11 comments
Milestone

Comments

@kdy1
Copy link
Member

kdy1 commented Jul 6, 2024

We want to collect ideas about AST changes.

@kdy1 kdy1 added this to the Planned milestone Jul 6, 2024
@magic-akari
Copy link
Member

magic-akari commented Jul 6, 2024

Use Function everywhere

const obj = {
    x() {}, // Function ✅
    set a(v) {}, // should use Function
    get b() {}, // should use Function
}

function foo() {} // Function ✅
const a = () => {} // should use Function
const b = () => expr; // We should use another form of representation, but it can be conveniently converted into a Function.

class clazz {
    x() {} // Function ✅
    set a(v) {} // Function ✅
    get b() {} // Function ✅
}

SWC AST Viewer


Use 👍 or 👎 to express your opinion.

@magic-akari
Copy link
Member

Merge ForInStmt/ForOfStmt into forXStmt


Use 👍 or 👎 to express your opinion.

@kdy1 kdy1 pinned this issue Jul 6, 2024
@kdy1 kdy1 unpinned this issue Jul 6, 2024
@kdy1 kdy1 mentioned this issue Jul 6, 2024
2 tasks
@devongovett
Copy link
Contributor

Try using an arena allocator (eg bumpalo) for heap allocated values like Vec and Box. Would require passing lifetimes around unfortunately but apparently this is where oxc gets some of its performance wins. Could be worth testing to see how much impact it has.

@magic-akari
Copy link
Member

Class

The attribute is_abstract should belong to the ClassDecl, but now it is an attribute of the Class.

SWC AST Viewer

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

  • BindingIdent should not have ident: Ident.
  • PrivateName should not have id: Ident.

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

Rename: ImportStarAsSpecifier => ImportNamespaceSpecifier.

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

Rename variants in TypeScript enums.

Current:

#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum TsTypeElement {
    #[tag("TsCallSignatureDeclaration")]
    TsCallSignatureDecl(TsCallSignatureDecl),

    #[tag("TsConstructSignatureDeclaration")]
    TsConstructSignatureDecl(TsConstructSignatureDecl),

    #[tag("TsPropertySignature")]
    TsPropertySignature(TsPropertySignature),

    #[tag("TsGetterSignature")]
    TsGetterSignature(TsGetterSignature),

    #[tag("TsSetterSignature")]
    TsSetterSignature(TsSetterSignature),

    #[tag("TsMethodSignature")]
    TsMethodSignature(TsMethodSignature),

    #[tag("TsIndexSignature")]
    TsIndexSignature(TsIndexSignature),
}

New:

#[ast_node]
#[derive(Eq, Hash, Is, EqIgnoreSpan)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum TsTypeElement {
    #[tag("TsCallSignatureDeclaration")]
    CallSignature(TsCallSignatureDecl),

    #[tag("TsConstructSignatureDeclaration")]
    Construct(TsConstructSignatureDecl),

    #[tag("TsPropertySignature")]
    Property(TsPropertySignature),

    #[tag("TsGetterSignature")]
    Getter(TsGetterSignature),

    #[tag("TsSetterSignature")]
    Setter(TsSetterSignature),

    #[tag("TsMethodSignature")]
    Method(TsMethodSignature),

    #[tag("TsIndexSignature")]
    Index(TsIndexSignature),
}

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

Fix TypeScript namespace vs module

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

Remove Key and merge PrivateName into PropName

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

  • JSX => Jsx

or

  • Ts => TS

@kdy1
Copy link
Member Author

kdy1 commented Jul 7, 2024

Take trait => Default trait

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

No branches or pull requests

3 participants