Description
I'm using commonjs modules on node.
I want to find a way to hide all implementation details from users of my modules.
But I cannot figure out how to protect my users from the dependencies on modules that are required by my modules.
For example:
I'm using nodemailer within a module I wrote.
I don't want the user of my module to need to know the implementation,
so I don't want them to have to reference or import nodemailer.
My module uses the Transport class from nodemailer.d.ts in its public interface.
I can't find a way to export the nodemailer.Transport class from my module, as if it was defined in my module.
I want my user to reference only my module (and not have to reference nodemailer).
Is there a way to do this? (I can't find it.)
If not, I suggest adding a way to export the declarations of a module (nodemailer in this case) so the user can use them without referencing the implementation-specific module. Of course, the compiler would track the reference, in order to resolve type errors.
For example, I would like to be able to write code such as;
MyModule.d.ts:
/// <reference path='nodemailer.d.ts' />
export nodemailer.Transport;
to make the symbol Transport available from my module, and then the user code might be:
/// <reference path='MyModule.d.ts' />
function f() : Transport {...}
Activity
RyanCavanaugh commentedon Nov 26, 2014
You can
export importsymbols from other modules (e.g.export import t = Transport.Foo). Does that solve your use case?