ES6 spec: `export default` HoistableDeclaration
Allen Wirfs-Brock
allen at wirfs-brock.com
Wed Nov 19 08:38:14 PST 2014
On Nov 19, 2014 6:54 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
>
> Quoting https://people.mozilla.org/~jorendorff/es6-draft.html#sec-exports
>
> > `export default` HoistableDeclaration
Note that the actual spec. text has a [Default] grammar parameter after HoistableDeclaration. That,'s important.
> > `export default` [lookahead ≠ `function`] AssignmentExpression `;`
>
> Questions:
>
> * Do these grammar rules mean that you have to put anonymous function expressions in parentheses? Is that desirable (given that it’s a frequent use case)?
No, HoistableDeclaration[Default] includes FunctionDeclaration that lacks a BindingIdentifier.
> * If the purpose of the first rule is to enable default-exporting of declarations (= no semicolon) – shouldn’t classes be included?
It has nothing to do with semicolons. It's so a function that is a default export can also have a local name binding.
We should also allow:
export default class Foo {};
where Foo is a module local binding.
Please file a bug.
Allen
>
> Thanks!
>
> Axel
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
> rauschma.de
>
>
>
More information about the es-discuss
mailing list