Benjamin Schmidt
Benjamin Schmidt

Reputation: 1061

Third level inheritance doesn't work

I have a few classes in CoffeeScript, that inherit from another class. The chain looks like this:

This works beautifully but when I try to introduce one more level to the ChooserPage-chain, specifically MultipleYesNoChooserPage extends YesNoChooserPage, suddenly I get an error:

Uncaught TypeError: Cannot read property 'prototype' of undefined

I checked the existence of the classes and got the following results:

To compare: Without MultipleYesNoChooserPage defined: enter image description here

With MultipleYesNoChooserPage defined: enter image description here

Does CoffeeScript have some maximum limit I don't know of (and cannot find anything) or is there any other reason for that?

The classes are loaded in the correct order.

Upvotes: 0

Views: 59

Answers (1)

Benjamin Schmidt
Benjamin Schmidt

Reputation: 1061

Okay, I got the solution, which happened by chance.

While trying to reproduce this I noticed that it doesn't happen outside the project. Because it confused me even more (I mean, how can the simple existence of a class let another one vanish) I completely deleted the file and re-created it. It worked, which let my confusion rise to an uncomprehensible level. Then it struck me:

To force the order of the files being loaded, they are named rather odd. In this case, this is what YesNoChooserPage and MultipleYesNoChooserPage are named like:

  • YesNoChooserPage.coffee
  • YZMultipleYesNoChooserPage.coffee

My editor (Sublime Text) lists them in the intended order but I noticed, the terminal doesn't. When I recreated the file, I accidentally named it 'YzMultipleYesNoChooserPage', causing a different order. This then worked.

Learned yet another thing.

Upvotes: 1

Related Questions