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;








1















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");











share|improve this question




























    1















    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");











    share|improve this question
























      1












      1








      1


      1






      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");











      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 24 at 23:29









      8Observer88Observer8

      637




      637






















          1 Answer
          1






          active

          oldest

          votes


















          2














          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");







          share|improve this answer




















          • 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











          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
          );



          );













          draft saved

          draft discarded


















          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









          2














          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");







          share|improve this answer




















          • 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















          2














          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");







          share|improve this answer




















          • 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













          2












          2








          2







          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");







          share|improve this answer















          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");








          share|improve this answer














          share|improve this answer



          share|improve this answer








          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












          • 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



















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript