The TypeScript compiler seems to produce wrong output as demonstrated below:
export default class TitleParser {}
Produces:
class TitleParser {
}
exports.TitleParser = TitleParser;
So the problem here is that I get an error when trying to use the class by importing it. The error: titleparser_1.default is not a function is shown when trying to instantiate it after importing the library:
import TitleParser from './TitleParser';
const parser = new TitleParser(); // the error occurs here
The fix for this is to export the class below, like this:
class TitleParser {}
export default TitleParser;
The above will produce the correct JavaScript code, i.e.
class TitleParser {}
exports.default = TitleParser;
Afterwards usage of the class doesn't throw an error anymore.
My compiler configuration is the following:
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"outDir": "../api",
"rootDir": "src",
"sourceMap": true,
"experimentalDecorators": true
And compiler version: 1.7.5
Is this a bug in the compiler or am I doing something wrong? The compiler never complains though.