I'm new to TypeScript and I having a problem with the same namespace used across multiple files:
file model.ts
export namespace MyCompany {
export class Model {
...
}
}
file webviewer.ts
import { Model } from './model';
export namespace MyCompany {
model : Model;
export class WebViewer {
use() : void {
this.model = new Model();
...
}
...
}
}
file index.ts
import { WebViewer } from './webviewer';
let webviewer = new WebViewer();
webviewer.use();
I cannot find any documentation on how to use MyCompany.Model in MyCompany.WebViewer class and MyCompany.WebViewer in index.ts file.
This document below contains many examples, but none of them treats my case, when the same namespace declared and used used across multiple files of the same library.
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#110-namespaces
UPDATE
Now I'm asking myself if it's OK using namespaces in every file. Probably there is a way to use .d.ts files where the classes can be exported inside namespaces, so later the library can be consumed as Acme.WebViewer etc