Class data member declarations proposal idea

Isiah Meadows isiahmeadows at gmail.com
Tue Aug 7 22:17:59 UTC 2018


Check out the various class-related proposals at
https://github.com/tc39/proposals. This is practically identical to the
existing class field proposal, just mod the type annotation thing.

On Tue, Aug 7, 2018, 15:17 Aaron Gray <aaronngray.lists at gmail.com> wrote:

> Hi,
>
> I am looking for help working on a TC39 proposal for declaring class data
> members, their default values, and possibly annotated typing. The fact that
> this is missing means there is little continuity between classes and
> existing prototypical object declarations. I have been moving Backbone.js
> and Underscore.js to modern class'ized JavaScript and have found that this
> will be needed for moving existing JavaScript libraries forward.
>
> abstracted syntax example :-
>
>     class X extends Y {
>         constructor() { ... }
>         defaults = {
>             a: 1,
>             b: 2
>         }
>         x : Integer = 3
>         aMethod() { ... }
>     }
>
> syntax modifications :-
>
>     ClassElement [Yield, Await]:
>         MethodDefinition [?Yield, ?Await]
>         "static" MethodDefinition [?Yield, ?Await]
>         FieldDefinition
>         "static" FieldDefinition
>         ;
>
>     FieldDefinition:
>         Identifier "=" PrimaryExpression
>
> This is probably slightly oversimplified at this stage with the syntactic
> rules, but this gives a preliminary idea of what is being proposed. This is
> similar to the following proposal
> https://github.com/tc39/proposal-class-fields but I have shown the idea
> of declaring subobject default value declarations.
>
> Type annotations would also be a good idea and allow at the least initial
> type checking for the default values, but this would not fit with subobject
> declarations and is a very complex area to take forward for any more level
> of type checking, although Facebook's Flow and MicroSoft's TypeScript, and
> a Babel plugin flow-runtime demonstrate that this is possible.
> https://github.com/codemix/flow-runtime
>
>
> --
> Aaron Gray
>
> Independent Open Source Software Engineer, Computer Language Researcher,
> Information Theorist, and amateur computer scientist.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180807/b46487da/attachment.html>


More information about the es-discuss mailing list