Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Can't subclass Sup.Behavior? #149

Open
GaetanRole opened this issue Oct 13, 2016 · 2 comments
Open

Can't subclass Sup.Behavior? #149

GaetanRole opened this issue Oct 13, 2016 · 2 comments

Comments

@GaetanRole
Copy link

Hi,

Whenever I try to subclass Sup.Behavior I get an error like this one:

capture du 2016-10-13 10-43-54

Is this not supported? I think it can be very useful to factor some common logic.

Here is my setup:

abstract class AObstacleBehavior extends Sup.Behavior {  
  public someMethod() {  
    Sup.log("Hey, I'm a parent method!");  
  }  
}  
class HighObstacleBehavior extends AObstacleBehavior {
  awake() {
  }

  update() {
  }
}
Sup.registerBehavior(HighObstacleBehavior);
@bilou84
Copy link
Contributor

bilou84 commented Oct 15, 2016

The script hierarchy matters in Superpowers so your AObstacleBehavior must be defined before the HighObstacleBehavior. Looks like TypeScript doesn't throw an error in this case because it's a class. Not sure what we could/should do about it. Any idea @elisee?

@elisee
Copy link
Contributor

elisee commented Oct 24, 2016

If the classes are in the same file, then there will be an error:


// TypeScript complains here
class B extends A {

}

abstract class A {

}

Not sure why we don't get errors when they are in different files. Maybe we have to tell the TypeScript compiler in which order the files will be concatenated, if that's possible?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants