Previous discussion about this: Inheritance TypeScript with exported class and modules
This is the source generated from the ValidatorMessage.class.ts:
///<reference path='./def/lib.d.ts'/>
///<reference path='./def/node.d.ts'/>
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var message = require("./Message.class");
var ValidatorMessage = (function (_super) {
__extends(ValidatorMessage, _super);
function ValidatorMessage() {
_super.apply(this, arguments);
}
return ValidatorMessage;
})(message.Message);
exports.ValidatorMessage = ValidatorMessage;
But when I load it on the browser (After Grunt.js merging and minifying), I get this error:
Uncaught TypeError: Cannot read property 'prototype' of undefined
Just after the line:
__.prototype = b.prototype, d.prototype = new __();
(~ligne 6 & 7)
I don't understand this error. Even if I put only the source code generated from TS without Grunt I get the same error.
Edit:
console.log(message):
function Message(message, data, status) {
"undefined" == typeof data && (data = !1), "undefined" == typeof status && (status = !1),
/**
* Constants.
*/
this.FIELD_NAME_MESSAGE = "m", this.FIELD_NAME_DATA = "d", this.FIELD_NAME_STATUS = "s",
this.EXCEPTION_BAD_JSON_CONTENT = 'Unable to parse JSON. Bad object/string attributes. (Missing message ("' + this.FIELD_NAME_MESSAGE + '" field) or status ("' + this.FIELD_NAME_MESSAGE + '" field)?',
this.EXCEPTION_BAD_JSON_TYPE = "Incorrect data type. Object or string expected.",
this._message = message, this._data = data, this._status = status;
}
var message = require("./Message.class");you can console.log(message) in Chrome or firefox to log it and see it's value. It should be a function so you couldconsole.log(typeof message);as well and see if it's a function.