This project is read-only.

Modules again

Topics: General
Jan 30, 2013 at 7:50 PM

It seems impossible to mix internal and external modules with the latest releases of TS.

I can only mix them if I import the external module at the top level (so outside the declaration of an internal module). But when I do that, internal modules that are split over several files do not "match" anymore.

is this the intended behavior, or am I overlooking something.

// Peter

Jan 30, 2013 at 7:58 PM

Well I think this is intended due to specification, read this issue:

Jan 30, 2013 at 8:20 PM

@jzvelc, thanks for pointing me that part of the spec. This time around I read it more carefully than when it first came out.

What it really means is that if a file imports an external module, it will become itself an external module (and thus will be loaded in a separate body). So that would explains the compiler errors I got. So not a bug, but the intended behavior.

I get more and more the feeling that the current module approach of TS is not optimal. I hope it will get revised so it becomes much more "natural" to use and you don't have to fight it all the time.

Jan 30, 2013 at 8:35 PM

It depends on what kind of project you are working on. You will probably use AMD for client side & CommonJS for e.g. Node.js. In my opinion external modules are ok as they are but the concept of internal modules is confusing, specially if you already wrote around 30 files and then realized that you need to import an external module (ouch!) =) The only thing I see here is to use classic require but that way you won't get type completion etc.