How to create an instance of concrete class from static method of abstract classDeclaring abstract method in TypeScriptTypescript - call child method from parent classCan't call method from constructorTyping a Typescript mixin function that can be applied to both classes and instancesIs it standard to access an static method from other classes?Export instance of class A as well as nested class A.BShould I prefer namespaces or classes with static functions?Using Derived-Class Instance Inside Base-Class to Call Base-Class Method with Derived-class DataDynamically call static method on variable typescript - theory / implementationAbstract Classes v Singletons v Public-statics in Typescript
When to use и or а as “and”?
How to represent jealousy in a cute way?
Arranging numbers in a circle such that the sums of neighbors and sums of diametric opposites are prime
What would the consequences be of a high number of solar systems being within close proximity to one another?
What is this Amiga 2000 mod?
If absolute velocity does not exist, how can we say a rocket accelerates in empty space?
Finding diameter of a circle using two chords and angle between them
Why do (or did, until very recently) aircraft transponders wait to be interrogated before broadcasting beacon signals?
How to Handle Many Times Series Simultaneously?
Placement of positioning lights on A320 winglets
Makefile for a simple Debian Repo
Linked novellas where humans are engineered to adapt to a variety of environments
Course development: can I pay someone to make slides for the course?
As easy as Three, Two, One... How fast can you go from Five to Four?
If the pressure inside and outside a balloon balance, then why does air leave when it pops?
Do Veracrypt encrypted volumes have any kind of brute force protection?
What is the "books received" section in journals?
Do they make "karaoke" versions of concertos for solo practice?
Should I list a completely different profession in my technical resume?
Why do I seem to lose data using this bash pipe construction?
Savage Road Signs
Part of my house is inexplicably gone
What's the difference between DHCP and NAT? Are they mutually exclusive?
What did the 8086 (and 8088) do upon encountering an illegal instruction?
How to create an instance of concrete class from static method of abstract class
Declaring abstract method in TypeScriptTypescript - call child method from parent classCan't call method from constructorTyping a Typescript mixin function that can be applied to both classes and instancesIs it standard to access an static method from other classes?Export instance of class A as well as nested class A.BShould I prefer namespaces or classes with static functions?Using Derived-Class Instance Inside Base-Class to Call Base-Class Method with Derived-class DataDynamically call static method on variable typescript - theory / implementationAbstract Classes v Singletons v Public-statics in Typescript
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I try to create an instance of concrete class from static method of abstract class. But I have this error:
Uncaught TypeError: Object prototype may only be an Object or null:
undefined
On this line of code in ConcreteClass.js: return extendStatics(d, b);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) ;
My 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");
typescript
add a comment |
I try to create an instance of concrete class from static method of abstract class. But I have this error:
Uncaught TypeError: Object prototype may only be an Object or null:
undefined
On this line of code in ConcreteClass.js: return extendStatics(d, b);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) ;
My 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");
typescript
add a comment |
I try to create an instance of concrete class from static method of abstract class. But I have this error:
Uncaught TypeError: Object prototype may only be an Object or null:
undefined
On this line of code in ConcreteClass.js: return extendStatics(d, b);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) ;
My 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");
typescript
I try to create an instance of concrete class from static method of abstract class. But I have this error:
Uncaught TypeError: Object prototype may only be an Object or null:
undefined
On this line of code in ConcreteClass.js: return extendStatics(d, b);
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) ;
My 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");
typescript
typescript
asked Mar 24 at 23:29
8Observer88Observer8
637
637
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The problem has to do with a circular import. AbstractClass
and ConcreteClass
are importing each other and the definition of each is making use of the other. The specific problem is that when ConcreteClass
is extending AbstractClass
, the AbstractClass
is still undefined, because it is waiting for ConcreteClass
to finish loading. As a result, the runtime is seeing something like vaguely this:
import AbstractClass from "./AbstractClass";
// at runtime AbstractClass has not finished loading yet so it is undefined
export class ConcreteClass extends undefined
public Method() : void
console.log("Method of ConcreteClass");
1
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329580%2fhow-to-create-an-instance-of-concrete-class-from-static-method-of-abstract-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem has to do with a circular import. AbstractClass
and ConcreteClass
are importing each other and the definition of each is making use of the other. The specific problem is that when ConcreteClass
is extending AbstractClass
, the AbstractClass
is still undefined, because it is waiting for ConcreteClass
to finish loading. As a result, the runtime is seeing something like vaguely this:
import AbstractClass from "./AbstractClass";
// at runtime AbstractClass has not finished loading yet so it is undefined
export class ConcreteClass extends undefined
public Method() : void
console.log("Method of ConcreteClass");
1
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
add a comment |
The problem has to do with a circular import. AbstractClass
and ConcreteClass
are importing each other and the definition of each is making use of the other. The specific problem is that when ConcreteClass
is extending AbstractClass
, the AbstractClass
is still undefined, because it is waiting for ConcreteClass
to finish loading. As a result, the runtime is seeing something like vaguely this:
import AbstractClass from "./AbstractClass";
// at runtime AbstractClass has not finished loading yet so it is undefined
export class ConcreteClass extends undefined
public Method() : void
console.log("Method of ConcreteClass");
1
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
add a comment |
The problem has to do with a circular import. AbstractClass
and ConcreteClass
are importing each other and the definition of each is making use of the other. The specific problem is that when ConcreteClass
is extending AbstractClass
, the AbstractClass
is still undefined, because it is waiting for ConcreteClass
to finish loading. As a result, the runtime is seeing something like vaguely this:
import AbstractClass from "./AbstractClass";
// at runtime AbstractClass has not finished loading yet so it is undefined
export class ConcreteClass extends undefined
public Method() : void
console.log("Method of ConcreteClass");
The problem has to do with a circular import. AbstractClass
and ConcreteClass
are importing each other and the definition of each is making use of the other. The specific problem is that when ConcreteClass
is extending AbstractClass
, the AbstractClass
is still undefined, because it is waiting for ConcreteClass
to finish loading. As a result, the runtime is seeing something like vaguely this:
import AbstractClass from "./AbstractClass";
// at runtime AbstractClass has not finished loading yet so it is undefined
export class ConcreteClass extends undefined
public Method() : void
console.log("Method of ConcreteClass");
edited Mar 25 at 1:18
answered Mar 25 at 1:02
Shaun LuttinShaun Luttin
66.2k39247306
66.2k39247306
1
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
add a comment |
1
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
1
1
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
I did not hear about the circular import problem before. Now I understand what I need to search in the Internet. Thank you very much.
– 8Observer8
Mar 25 at 11:34
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329580%2fhow-to-create-an-instance-of-concrete-class-from-static-method-of-abstract-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown