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@mozilla.org https://mail.mozilla.org/listinfo/es-discuss