Creating an Angular2 app, I am facing the following problem, when calling the constructor of another class inside the constructor of first class.
First Class code
import SecondClass from './second-class'
export class FirstClass {
someVar:string;
secondClass:SecondClass;
constructor(firstClass?: FirstClass) {
someVar='test';
secondClass= new SecondClass;
}
}
Second Class code:
export class SecondClass {
someOtherVar:string;
constructor(secondClass?:SecondClass) {
someOtherVar='test';
}
}
Would give me the error: ORIGINAL EXCEPTION: TypeError: second_class_1.default is not a constructor
Content of ./second-class
System.register([], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var SecondClass;
return {
setters:[],
execute: function() {
SecondClass = (function () {
function SecondClass(secondClass) {
this.someOtherVar='test';
}
return SecondClass;
}());
exports_1("SecondClass", SecondClass);
}
}
});
//# sourceMappingURL=second-class.js.map
This is the compiled output from Typescript compiler
./second-class.defaultis a javascript reserved word.