Extend class that implements Interface shadows name

Consider the following Typescript classes:

interface ITest {
  example(): string;
}

class A implements ITest {
  example() {
    return 'Test A';
  }
}

class B extends A {
  example() {
    return 'Test B';
  }
}

This translates to the following Javascript code (see http://www.typescriptlang.org/Playground):

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;
    d.prototype = new __();
};
var A = (function () {
    function A() {
    }
    A.prototype.example = function () {
        return 'Test A';
    };
    return A;
})();
var B = (function (_super) {
    __extends(B, _super);
    function B() {
        _super.apply(this, arguments);
    }
    B.prototype.example = function () {
        return 'Test B';
    };
    return B;
})(A);

The code runs correctly and gives the result

"Test A"
"Test B"

But checking this code with JSLint gives the warning

One warning 17

‘B’ is already defined.

JsLint seems to have problems with __extends(B, _super). But of course this is necessary for extending the class. So how can I make sure that JSLint does not complain when using inheritance in TypeScript?


Source: oop

Leave a Reply