On 5 July 2012 19:33, Russell Leggett <[email protected]> wrote:
> Oh, I also meant to ask - I do have a question of my own. It seems so
> basic, but I can't figure it out. If I have a file that contains two
> modules - let's say in foo.js
>
> ------- foo.js ----------------
> module Foo {
> export let x = 42;
> }
> module Bar {
> export let y = 12;
> }
>
> and I try to do:
>
> import y from "foo.js"
>
> What happens? Similar problem if I try to do
>
> import "foo.js" as Foo
>
> Am I incorrect in thinking that there can be more than one top level
> module? Or is it that an imported file is automatically a module, and
> therefore Foo and Bar are nested modules in this case? Would I then have to
> say "export module Foo..." and later "import Foo from "foo.js;"?
>
Yes, an imported file is a module body by itself, so Foo and Bar are nested
modules. Your first import hence is an error, and the second one binds a
module Foo with members Foo.Foo and Foo.Bar.
/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss