Typically, Typescript modules are declared like
declare module MyModule {
....
}
but sometimes I also see it like
declare
"Internal modules" === “namespaces”
“External modules” === “modules”
A note about terminology: It’s important to note that in TypeScript 1.5, the nomenclature has changed. “Internal modules” are now “namespaces”. “External modules” are now simply “modules”, as to align with ECMAScript 2015’s terminology, (namely that module X { is equivalent to the now-preferred namespace X {).
/*
Note: All of these files in the same folder, i.e. the same path!
*/
// declare a namespace, demoNamespace.d.ts
declare namespace "DemoNamespace" {
export function fn(): string;
}
// using a namespace, demoNamespaceModule.ts
import * as n from "demoNamespace";
//let f = new n.DemoNamespace.fn(); ???
// export a module, demoModule.ts
export class Alpha { /* ... */ }
export class Beta { /* ... */ }
// using a module, demoModuleTest.ts
import * as m from "./demoModule";
let a = new m.Alpha();
let b = new m.Beta();
namespaces-and-modules namespaces modules