This document specifies the extensions to the core ESTree AST types to support the ES2022 grammar.
These language extensions cover following class features proposals:
extend interface ClassBody {
body: [ MethodDefinition | PropertyDefinition | StaticBlock ];
}
interface PropertyDefinition <: Node {
type: "PropertyDefinition";
key: Expression | PrivateIdentifier;
value: Expression | null;
computed: boolean;
static: boolean;
}
- When
key
is aPrivateIdentifier
,computed
must befalse
.
extend interface MethodDefinition {
key: Expression | PrivateIdentifier;
}
- When
key
is aPrivateIdentifier
,computed
must befalse
andkind
can not be"constructor"
.
interface PrivateIdentifier <: Node {
type: "PrivateIdentifier";
name: string;
}
A private identifier refers to private class elements. For a private name #a
, its name
is a
.
extend interface MemberExpression {
property: Expression | PrivateIdentifier;
}
- When
property
is aPrivateIdentifier
,computed
must befalse
. - When
object
is aSuper
,property
can not be aPrivateIdentifier
.
interface StaticBlock <: BlockStatement {
type: "StaticBlock"
}
A static block static { }
is a block statement serving as an additional static initializer.
extend interface BinaryExpression <: Expression {
left: Expression | PrivateIdentifier;
}
left
can be a private identifier (e.g.#foo
) whenoperator
is"in"
.- See Ergonomic brand checks for Private Fields for details.