Imagine I have a module where I define a namespace with various properties. Here's an example:
declare module "database" {
export namespace Database {
namespace statics {
type static1 = any;
type static2 = any;
}
}
const database: Database;
export default database;
}
To access these properties, I can use
import { Database } from "database"
and then refer to Database.statics.static
as a type.
Now, I want to create another module that allows direct import of the statics. For instance:
declare module "database/statics"
I want to avoid redefining all the type definitions since there could be many more than shown in this example. I attempted to move the module definitions out, but I'm unsure how to achieve something like this:
declare namespace Database { ... }
declare module "database/statics" {
export = Database.statics;
}
This results in
Property 'statics' does not exist on type 'Database'
.
In essence, my question boils down to: Is there a way to export a namespace from a module when it is declared in another module?