I am using typescript for a somewhat complex ionic2 project.
I have a BasePage which is the base class for all ionic pages. And I have a BaseTabPage extends BasePage. After I create multiple subclass or BaseTabPage, I start to see this error undeterministically:
“TypeError: Cannot read property ‘prototype’ of undefined” in _extends method.
It seems the TS compiler misordered the subclass before the base class so that the this error happens.
Is there any body saw this already and knows how to reslove it?
It seems that this is a TypeScript issue(find more details in this SO answer) which is currently scheduled for 2.1(which means that it might take few months to more than half an year until it’s ready/resolved) so you could subscribe/vote for it:
Runtime Error
Cannot read property 'prototype' of undefined
Does anyone have a solution yet?
Reading above, it could be related to the order in which a subclass and baseclass are declared. I am using a baseclass with a subclass. Where do you change the order in which they are declared, is it in the imports? In what file?
Funny thing is my code was working fine, and suddenly started to get this error, even without me changing the base or sub classes. I did make a change to another tys file, which I have now reverted, but still get the error.
Not that you should have any reason to care about my opinion. but I think inheritance is overused in general and an especially bad idea in JavaScript. Can you achieve your goal with composition instead?
I could, other classes also inherit from the super class too (common functionality), but I could make use of composition instead. It only mean I need to refractor quite a lot of code.