There are several options:
- You could just define another variable in which you put the class:
Code:
const ConfigurationManagerModule = require('./ConfigurationManager');
const ConfigurationManager = ConfigurationManagerModule.ConfigurationManager;
new ConfigurationManager(...);
- You could set the whole export of the module as the class if the module exports nothing but this class.
Code:
export = class ConfigurationManager {
}
const ConfigurationManager = require('./ConfigurationManager');
new ConfigurationManager();
For the second option, the difference between export class ..
and export = class ...
, is that in the first case we specify something to add to the export, in the second we specify that the whole export is the class. In terms of the generated JS, the first options generates this:
var ConfigurationManager = /** @class */ (function () {
function ConfigurationManager() {
}
return ConfigurationManager;
}());
exports.ConfigurationManager = ConfigurationManager;
while the second generates this:
module.exports = /** @class */ (function () {
function ConfigurationManager() {
}
return ConfigurationManager;
}());