Trying to instantiate a concrete class from a static method of an abstract class is resulting in the following error:
Uncaught TypeError: Object prototype may only be an Object or null: undefined
This error occurs on this line in ConcreteClass.js: return extendStatics(d, b);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
Related project files:
Program.ts
import { AbstractClass } from "./AbstractClass";
class Program
{
public static Main()
{
let instance = AbstractClass.CreateObject();
instance.Method();
}
}
Program.Main();
AbstractClass.ts
import { ConcreteClass } from "./ConcreteClass";
export abstract class AbstractClass
{
public static CreateObject()
{
return new ConcreteClass();
}
public abstract Method(): void;
}
ConcreteClass.ts
import { AbstractClass } from "./AbstractClass";
export class ConcreteClass extends AbstractClass
{
public Method() : void
{
console.log("Method of ConcreteClass");
}
}