My Typescript configuration seems to be causing some issues, even though everything works fine without TS. Could the problem lie in my .d.ts file? And do I really need it for webpack?
I have a basic NPM module:
index.js:
var MyMathTS = function(a, b){
this.sum = a + b;
};
exports = MyMathTS;
index.d.ts:
declare class MyMathTS {
constructor(x: number, y: number);
sum(x: number, y: number) : number;
}
This is the code in main.ts:
import "mymathts16";
var mm = new MyMathTS(2, 3);
console.log(mm);
The output from webpack displays:
/******/ ([
/* 0 */
/***/ (function(module, exports) {
var MyMathTS = function(a, b){
this.sum = a + b;
};
exports = MyMathTS;
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mymathts16__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mymathts16___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_mymathts16__);
var mm = new MyMathTS(2, 3);
console.log(mm);
/***/ })
/******/ ]);
However, when I check the console, I encounter this error message:
https://i.sstatic.net/n0OmV.png
Interestingly, Angular doesn't seem to have any issues.