bathos/Ecmascript-Sublime

Missing ES7 features

aziz opened this issue · 2 comments

aziz commented

sublimehq/Packages#876 also applies to this package.

  • Async methods inside of a class
class SomeClass {
    async instanceMethod() {
    }

    async static someStaticMethod() {
    }
}
  • Class static and instance properties (taken from Babel site)
class Bork {
    //Property initializer syntax
    instanceProperty = 'bork';
    boundFunction = () => {
        return this.instanceProperty;
    }

    //Static class properties
    static staticProperty = 'babelIsCool';
    static staticFunction = function() {
        return Bork.staticProperty;
    }
}

The first example there is a syntax error. It’s static async.

The second isn’t an ES7 feature, it’s a stage 1 proposal, and also a syntax error*, albeit one Babel currently permits; you’ve omitted the separating semicolon after the second assignment.

* Maybe. We just don’t know yet how ASI will work, or if it will work, in this situation, since to date ASI applies specifically to statements. Here the semicolons aren’t statement separators, but they fulfill a similar role and are required for disambiguating sequences like foo = 1 [bar]() {}.

(BTW, it may help to clarify why static is always the first keyword, since the order isn’t arbitrary. The presence or absence of static is an instruction "about the class": in the latter case it says "this next one is a property definition for the constructor" and in the former it says "this next one is a property definition for the prototype". In contrast, async, like *, is a keyword that indicates a special kind of wrapped function; in this sense it is part of the function definition rather than part of the class definition.)