I have converted big JS project to typescript (as I C# programmer) using in PhantomJs. The problem is interpreter (phantomjs) fails while executing this js file.
D:\My\phantomjs-1.9.7-windows\phantomjs.exe --load-images=false --ssl-protocol=any --web-security=no --cookies-file=cookies C:\Users\alex\Projects\robot\bo.js
TypeError: 'undefined' is not an object (evaluating 'b.prototype')
the code is:
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]
function __() { this.constructor = d; }
__.prototype = b.prototype; // <<< here
d.prototype = new __();
};
So. I think the problem is somewhat related to inheritance. Have any one encountered this problem? Any help is appreciated. Thanks.
The most common cause of this error is that you are loading the files in the wrong order... for example...
File A
class ExampleClass {
someMethod() {
alert('Hello World');
}
}
File B
class ExampleSubClass extends ExampleClass {
}
If you were to load File B
before File A
, you would get the exact error you are describing. (This includes forgetting to load File A
or loading File A
after File B
).
Fixes
If you are combining all of your files into a single file (and you are probably using a _references.ts
file) make sure the references are in the right order.
/// <reference path="file-a.ts" />
/// <reference path="file-b.ts" />
If you are using script tags, it is the similar fix (making sure you are using .js
extensions and checking the order of loading)...
<script src="file-a.js"></script>
<script src="file-b.js"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With