Uncaught TypeError: Cannot read property 'reopen' of undefined


(Shiv Kumar) #1

I think that a recent commit is preventing me from re-opening ApplicationRoute, which is breaking a couple of my plugins. I’m now getting the following error:

Uncaught TypeError: Cannot read property 'reopen' of undefined

Here’s what one of my Javascript files looks like in my plugin:

Discourse.ApplicationRoute.reopen({
  actions: {
    // do stuff
  }
});

What do I need to do to get this working again? Thanks!


(Sam Saffron) #2

@eviltrout can you have a look at this?


(Régis Hanol) #3

Guessing it’s related to the recent convertion to ES6

https://github.com/discourse/discourse/commit/90e2f1893c1a74bb50c450c2b10cafe60096a41a


(Robin Ward) #4

@shivermetimbers sorry about this. I started converting routes yesterday and they weren’t covered by my compatibility layer. I’ve made sure they are and your patch should work now with the latest master.

Going forward, you should put those patches into an initializer, but I can help you with that when the time comes.


(Jeff Atwood) #5

(Jeff Atwood) #6

(Shiv Kumar) #7

Help! reopen is now fixed, but on is broken:

Discourse.ApplicationRoute.on('activate', function() {
  // do something
});

Also, is there a tutorial or topic somewhere that explains how to properly work with ES6? It seems that every time something is moved to ES6, something breaks on our end :frowning:


(Sam Saffron) #8

@eviltrout be sure to look at this first thing tomorrow.


(Robin Ward) #9

Sorry I had a typo and it was literally a one character change.

https://github.com/discourse/discourse/commit/f5cba39c898654bd83f05308f5a4a1a986138ff8

If you update to latest it should work


(Shiv Kumar) #10

That fixed it. Thanks!


(Jeff Atwood) #11

This topic was automatically closed after 2 days. New replies are no longer allowed.