Restructuring TypeScript internal modules to external modules

Viewed 966

I have a website that uses a large typescript code base. All clases as in their own files, and wrapped with an internal module like so:

file BaseClass.ts

module my.module {
  export class BaseClass {
  }
}

file ChildClass.ts

module my.module {
  export ChildClass extends my.module.BaseClass  {
  }
}

All file are included globally with script tags, in the appropriate order (using ASP.NET Bundling).

I would like to move to a more modern setup and use webpack. I would like my module syntax to use whatever the new ECMASCRIPT module standard is. But there is much code using the existing "module namespaces" so I would like an update path that will support this type of code -

let x = new my.module.ChildClass();

So I think I need to have something like this -

import * as my.module from ???;

Or use namespaces?

However, if that is not best practices, I would like to stick with best practices. The internal modules are currently very helpful for organizing the different application layers and services...

How would I accomplish this since the "module" is across many files? Really, all I am trying to accomplish is to have a namespace, and get away from global scripts.

1 Answers
Related