diff --git a/experimental/class-features.md b/experimental/class-features.md new file mode 100644 index 0000000..63c37e4 --- /dev/null +++ b/experimental/class-features.md @@ -0,0 +1,61 @@ + +# Class Features + +This experimental extension covers three class features proposals: +[Class Fields], [Static Class Features] and [Private Methods]. + +## ClassBody + +```js +extend interface ClassBody { + body: [ MethodDefinition | PropertyDefinition ]; +} +``` + +## PropertyDefinition + +```js +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 + +```js +extend interface MethodDefinition { + key: Expression | PrivateIdentifier; +} +``` + +- When `key` is a `PrivateIdentifier`, `computed` must be `false` and `kind` can not be `"constructor"`. + +### PrivateIdentifier + +```js +interface PrivateIdentifier <: Node { + type: "PrivateIdentifier"; + name: string; +} +``` + +A private identifier refers to private class elements. For a private name `#a`, its `name` is `a`. + +```js +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`. + +[Class Fields]: https://github.com/tc39/proposal-class-fields +[Static Class Features]: https://github.com/tc39/proposal-static-class-features/ +[Private Methods]: https://github.com/tc39/proposal-private-methods diff --git a/experimental/private-fields-in-in.md b/experimental/private-fields-in-in.md index 9a680ed..f6e9a1b 100644 --- a/experimental/private-fields-in-in.md +++ b/experimental/private-fields-in-in.md @@ -6,10 +6,10 @@ ```js extend interface BinaryExpression <: Expression { - left: Expression | PrivateName; + left: Expression | PrivateIdentifier; } ``` -- `left` can be a private name (e.g. `#foo`) when `operator` is `"in"`. +- `left` can be a private identifier (e.g. `#foo`) when `operator` is `"in"`. [proposal-private-fields-in-in]: https://github.com/tc39/proposal-private-fields-in-in