Answer the question
In order to leave comments, you need to log in
How to get rid of namespace during module import?
There is a /lib/Response.ts module:
export class Response {
/* bla-bla */
}
import Response = require('./lib/Response');
var response = new Response.Response();
import Response = require('./lib/Response');
var response = new Response();
Answer the question
In order to leave comments, you need to log in
Why not import with the ES6 import mechanism? TypeScript supports it very well.
import {Response} from './lib/Response';
var response = new Response();
I like this:
Module code
function newClass (settings) {
return new Class(settings);
}
function Class(settings){
this.settings = settings;
}
Class.prototype.someMethod = function () {
var _this = this;
console.log(_this.settings);
};
module.exports = newClass;
var classInstance = require('./classFile.js')({'some':'settings'});
classInstance.someMethod();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question