Reputation: 1061
I have a few classes in CoffeeScript, that inherit from another class. The chain looks like this:
Page
ChooserPage
YesNoChooserPage
CommentPage
SimplePage
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:
Page
existsChooserPage
existsYesNoChooserPage
doesn't exist (undefined)MultipleYesNoChooserPage
doesn't exist (undefined, obviously)To compare:
Without MultipleYesNoChooserPage defined:
With MultipleYesNoChooserPage defined:
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
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:
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