Why is "export default var a = 1;" invalid syntax?

Dave Herman dherman at mozilla.com
Tue Dec 16 08:06:30 PST 2014


On Mon, Dec 15, 2014 at 11:50 PM, Glen Huang <curvedmark at gmail.com> wrote:
>
> Would you consider adding this:
>
> Syntax
> export default var VariableDeclaration;
>

I should first say: no module syntax changes for ES6. But we can discuss
extensions for post-ES6 proposals.

I was resistant to this syntax at first but I've warmed to it. In
particular, it has a consistent syntax, and can be given a consistent
semantics, to `export default function` and `export default class`. IOW, it
creates a local binding that is also exported, but renamed to `default`.
This does feel like a missing case on top of those other "locally named
default export" forms.

Note that if we add `export default var` we also have to add `export
default let` and `export default const`.

I think this is worth proposing, folded in with other proposed post-ES6
extensions to the module syntax (in particular the module metadata syntax).
I'll be happy to do this.

Thanks for your input!

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141216/4c9f6a9f/attachment.html>


More information about the es-discuss mailing list