I have this code in TS to create an instance of ConnectRoles Middleware in Express:
let user = new ConnectRoles(config);
this is what the middleware expects to be able to initialize, a simple call to a constructor, however after transpiling, the resulting javascript code looks like this:
let user = new connect_roles_1.default(config);
I am importing this class in TS using:
import ConnectRoles from "connect-roles";
which translates to:
const connect_roles_1 = require("connect-roles");
in JS, is it possible that the way in which I am instantiating/importing the class may be the issue here? I can remove manually the "default" method that is causing errors in the code in the JS, but this defeats the purpose of using a transpiler, specially if things like this start happening more often.
One more thing, this is my tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": { "*": ["types/*"] },
"target": "es2015",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"outDir": "app",
"sourceMap": true,
"watch": true
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts",
],
"compileOnSave": true,
"buildOnSave": true,
"atom": {
"rewriteTsconfig": false
}
}
Any ideas will be very appreciated, thanks!