Open kdy1 opened 2 months ago
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 ✅
}
Use 👍 or 👎 to express your opinion.
Use 👍 or 👎 to express your opinion.
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.
Class
The attribute is_abstract
should belong to the ClassDecl
, but now it is an attribute of the Class
.
BindingIdent
should not have ident: Ident
.PrivateName
should not have id: Ident
.Rename: ImportStarAsSpecifier
=> ImportNamespaceSpecifier
.
Rename variants in TypeScript enums.
#[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),
}
#[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),
}
Fix TypeScript namespace vs module
Remove Key
and merge PrivateName
into PropName
JSX
=> Jsx
or
Ts
=> TS
Take trait => Default trait
Perhaps I should open a separate issue for this, but would you consider supporting a way to include custom types of expressions in the AST? For example:
enum Expr {
// ...
Custom(Box<dyn CustomExpr>)
}
trait CustomExpr: Eq, Hash, ..., swc_ecma_codegen::Node {}
The use case for this that I have is to store placeholder references in the AST for dependencies such as require
, new URL(...)
and other expressions that might get replaced by a bundler.
I did something similar to this in lightningcss, except using generics instead of dyn
. But I'd recommend not doing that - it was quite painful to propagate the generics everywhere.
Edit: Just remembered about a previous discussion of this: #7874. Was there any further progress on that?
We want to collect ideas about AST changes.