1

First of all I have to say that this question is a duplicate of Extend Global Class with Another Global Class in Coffeescript/Meteor but the answer for that one it's not working for me.

I have been trying moving files in different places with different names following the Meteor load order but I keep getting a Reference Error.

I have to files in the same folder:

//File A.js
console.log("A.js");
class A{
  constructor(){
    this.name = "Parent";
  }
  sayWho(){
    console.log(this.name);
  }
}

And

// File B.js
console.log("B.js")
class B extends A{
  constructor(){
    super();
    this.name = "Child B";
  }
}

The output is

A.js
B.js
ReferenceError: A is not defined

So it's obvious that A.js loads before B.js but still doesn't work. I can create an instance of A in A.js and use it in B.js so that is more proof things are loading in the correct order.

What am I missing here?

Thanks for the help.

Community
  • 1
  • 1
Aumon
  • 39
  • 3
  • The class is defined in the module scope. If it is not exported, then it is not accessible from outside. Why would you want to use global variables when you don't have to? – MasterAM Jun 08 '17 at 10:25
  • The idea is to have a language class where the components can load their strings. That's why I want something global, to be used anywhere. In the other hand I have no idea of how Meteor or Angular work so I am probably doing many wrong things. – Aumon Jun 08 '17 at 10:31
  • You can export it from your file and import it wherever you need it. You did not mention using Angular and I don't really think that this is related to it (although Angular generally champions IoC instead of importing) – MasterAM Jun 08 '17 at 10:35

0 Answers0