Closed
Description
We occasionally get people in the IRC channel asking about their transpiled JS failing with TypeError: undefined is not an object
. It happens when accessing b.prototype
inside __extends
because the child class is before the base class, but they often think it's a bug in __extends
. Would it make sense to detect if b
is undefined at the start of the function and throw an appropriately worded error? Eg:
var __extends = this.__extends || function (d, b) {
if (b === undefined) { throw new Error("The base class is not defined. Did you put the child class before the base class?"); }
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};