0

There is a specific typescript definition that I cannot currently get working:

mapping.ts
class Mapping {
//
}
var mapping = new Mapping();
export = mapping;

Which enables the use:

import _mapping = require('mapping');
_mapping.doSomething();

However I cannot quite get to the solution of how my mapping.d.ts should be structured to show this and cannot get it to compile.

mapping.d.ts
export var mapping: Mapping;

This fails since the usage would now be:

 _mapping.mapping.doSomething();

Any suggestions would be appreciated besides updating the usage to include the object name.

1 Answer 1

1

You can use the syntax export = in the definitions file:

// mapping.d.ts
let mapping: Mapping;
export = mapping;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.