Encountering an issue with extending items, resulting in:
Uncaught TypeError: Cannot read property 'prototype' of undefined
After researching, it seems that items must be defined in a specific order. I have organized them accordingly but still face the error.
This error occurs during runtime in the browser, not at compile time. The files are compiled into one using browserify and tsify.
My entry point main.ts:
import GameSmartWeb from './GameSmartWeb';
window.gs = new GameSmartWeb();
It then references GameSmartWeb.ts which includes a GUI class:
import GUI from './apis/GUI';
export default class GameSmartWeb {
public get gui(): GUI { return new GUI(); }
}
The GUI class in apis/GUI.ts is structured like this:
export default class GUI extends GameSmartWeb {
public get rewards(): Rewards { return new Rewards(); }
}
class Rewards extends GUI {
// Additional methods
}
The browser highlights the error at this line:
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); // Error occurs here
};
var GUI = (function (_super) {
__extends(GUI, _super); // This calls the function
// More autogenerated code
});