Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.5 KB

es2022.md

File metadata and controls

62 lines (46 loc) · 1.5 KB

This document specifies the extensions to the core ESTree AST types to support the ES2022 grammar.

Classes

These language extensions cover three class features proposals: Class Fields, Static Class Features and Private Methods.

ClassBody

extend interface ClassBody {
    body: [ MethodDefinition | PropertyDefinition ];
}

PropertyDefinition

interface PropertyDefinition <: Node {
    type: "PropertyDefinition";
    key: Expression | PrivateIdentifier;
    value: Expression | null;
    computed: boolean;
    static: boolean;
}
  • When key is a PrivateIdentifier, computed must be false.

MethodDefinition

extend interface MethodDefinition {
    key: Expression | PrivateIdentifier;
}
  • When key is a PrivateIdentifier, computed must be false and kind can not be "constructor".

PrivateIdentifier

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 a PrivateIdentifier, computed must be false.
  • When object is a Super, property can not be a PrivateIdentifier.