Below if I import Entity
I get the posts's subject error (TypeError: Object prototype may only be an Object or null: undefined), but if I replace the import with the actual Entity
declaration the code runs fine.
Stackblitz demo here.
This is Customer.ts
in the form that produces the error when I run the code with ts-node
:
index.ts
export { Customer } from "./Customer";
export { Entity } from "./Entity";
Customer.ts
import { Entity } from "./index";
export class Customer extends Entity {
sku: string;
constructor(po: any) {
super();
this.sku = po.sku;
}
}
Entity.ts
export abstract class Entity {
id?: string;
}
Run.ts (The test code)
import {Customer} from "./";
let c = new Customer({
name: "Bob"
});
console.log(c);
If I replace the Entity
import with the declaration like this:
export abstract class Entity {
id?: string;
}
export class Customer extends Entity {
sku: string;
constructor(po: any) {
super();
this.sku = po.sku;
}
}
Then Run.ts
logs this:
Customer { sku: undefined }
In other words it runs fine and produces no errors. Thoughts?