Module syntax

Axel Rauschmayer axel at rauschma.de
Mon Jun 3 12:47:07 PDT 2013


We may be able to have both: convenient default imports and convenient non-default imports, if we bring back `export =` (which, IIRC, has been proposed a while ago) and introduce `import =` as an analog. Example:

module "jquery" {
    export = {
        ...
    };
}

import $ = "jquery";

Not completely happy with it (as both look like assignments), but it complements the non-default case nicely and everything combined may be the best we can do overall.


Remaining changes – wiki:
    import { encrypt, decrypt } from "crypto"; // binding a module's exports to variables
    import { encrypt as enc } from "crypto";   // binding and renaming one of a module's exports
    export { foo, bar } from "crypto";         // re-exporting specified exports from another module
Brace-free:
    import encrypt, decrypt from "crypto"; // binding a module's exports to variables
    import encrypt as enc from "crypto";   // binding and renaming one of a module's exports
    export foo, bar from "crypto";         // re-exporting specified exports from another module
-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130603/43ccd0a3/attachment-0001.html>


More information about the es-discuss mailing list