TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Error when extends a declared .d.ts class.

Open acopalipsis opened this issue 11 years ago • 1 comments

import Index from './index';
export class Main {
    public index: Index;
    constructor() {
        this.index = new Index();
    }
}
import {SomeSuperClass} from 'some.js';

export default class Index extends SomeSuperClass{
    constructor() {
        super();
    }
}
declare module SOME {
    export class SomeSuperClass{
        constructor();
        execute();
    }
    export class SomeSubClass{
        constructor();
        execute();
    }
}

declare module 'some.js' {
    export = SOME;
}
System.register(['./index'], function(exports_1) {
    var index_1;
    var Main;
    return {
        setters:[
            function (_index_1) {
                index_1 = _index_1;
            }],
        execute: function() {
            Main = (function () {
                function Main() {
                    this.index = new index_1.default();
                }
                return Main;
            })();
            exports_1("Main", Main);
        }
    }
});

var __extends = (this && 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 __();
    };
System.register(['some.js'], function(exports_1) {
    var some_js_1;
    var Index;
    return {
        setters:[
            function (_some_js_1) {
                some_js_1 = _some_js_1;
            }],
        execute: function() {
            Index = (function (_super) {
                __extends(Index, _super);
                function Index() {
                    _super.call(this);
                }
                return Index;
            })(some_js_1.SomeSuperClass);
            exports_1("default", Index);
        }
    }
});

So is compiled by default and does not work. If you omit the __extends that work. Why? How can I fix it?

System.register(['some.js'], function(exports_1) {
    var some_js_1;
    var Index;
    return {
        setters:[
            function (_some_js_1) {
                some_js_1 = _some_js_1;
            }],
        execute: function() {
            Index = (function (_super) {
                __extends(Index, _super);
                function Index() {
                    _super.call(this);
                }
                return Index;
            })(some_js_1.SomeSuperClass);
            exports_1("default", Index);
        }
    }
});
var __extends = (this && 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 __();
};

acopalipsis avatar Aug 25 '15 21:08 acopalipsis

looks like a duplicate of #3655. Can you give typescript@next a try. (npm install typescript@next).

mhegazy avatar Aug 26 '15 02:08 mhegazy