Let's consider a particular situation: I am in the process of creating typescript definitions for two commonJS modules, A and B. Module B has a dependency on module A, and to make things easier, B directly exports A as a property B.A
so that users do not have to explicitly call require('A')
in their code.
The question at hand is how can I properly define the typescript definition for module B to export A as a property of B? Here is what I've tried:
Module A exports various members like this:
export const foo = 'bar';
Then, in module B, I attempted:
import * as A from 'A';
export A;
and
import * as a from 'A';
export var A : a;
However, neither approach resulted in valid typescript module definitions.
The desired outcome is to be able to write the following in the consuming typescript code:
import B = require('B');
console.log(B.A.foo);
What is the correct method to define module B's type definitions in order to export A as a property of B?