This project is read-only.

Is extends broken/unavailable in TS 0.8.3 + ES3?

Topics: General
Mar 5, 2013 at 12:33 AM
I've got a class that extends another. Very simple stuff. But when it compiles (which it does without error) it is creating the following JS which debugging tools moan about:
var __extends = this.__extends || function (d, b) {
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
The above is inserted above the JS creating my class and gives the wonderful "Uncaught TypeError: Cannot read property 'prototype' of undefined" error.

This is in TS 0.8.3 and I'm using ES3 and --out.
Mar 5, 2013 at 1:25 AM
Is the derived class above the base class in the file? You'll need to have the derived class written after the base class.
Mar 5, 2013 at 1:36 AM
Never mind, the issue was nothing to do with the above but to do with the way extends works.

I had a class (say classA) that extended another class (classB), and I wanted to pass a reference of classA to classB, but the second I did that it got its knickers in a twist and threw the error above. Never mind, the code was a bit hacky anyway but figured I'd post in case it catches anyone else out :)