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
keyis aPrivateIdentifier,computedmust befalse.
extend interface MethodDefinition {
key: Expression | PrivateIdentifier;
}- When
keyis aPrivateIdentifier,computedmust befalseandkindcan 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
propertyis aPrivateIdentifier,computedmust befalse. - When
objectis aSuper,propertycan 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;
}leftcan be a private identifier (e.g.#foo) whenoperatoris"in".- See Ergonomic brand checks for Private Fields for details.
See Arbitrary module namespace identifier names for more details.
extend interface ImportSpecifier <: ModuleSpecifier {
imported: Identifier | Literal;
}If imported is a Literal, imported.value must be a string without lone surrogate.
extend interface ExportSpecifier <: ModuleSpecifier {
local: Identifier | Literal;
exported: Identifier | Literal;
}local can be Literal only if the source of the ExportNamedDeclaration of the parent of this node is not null. e.g. export { "foo" as "foo" } from "mod" is valid, export { "foo" as "foo" } is invalid.
If exported/local is Literal, exported.value/local.value must be a string without lone surrogate.
extend interface ExportAllDeclaration {
exported: Identifier | Literal | null;
}If exported is Literal, exported.value must be a string without lone surrogate.