Skip to content

Add ability to specify the external __extends function #2009

@Taritsyn

Description

@Taritsyn

Currently when implementing of class inheritance in the output JS-file automatically added the following code:

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 __();
};

And calls of the following kind:

__extends(MyClass, _super);

In the presence of large amount of TS-files in the project, this leads to a significant increase size of concatenated file (especially when using AMD-modules).

It would be nice to add a new compiler option (it can be called externalExtendsFunction), which would be allow to specify the name of analog __extends function from external script. For example, if we set to the externalExtendsFunction option a value equal to util.extends, then the __extends function code will not be generated in the JS-file and its calls will be as follows:

util.extends(MyClass, _super);

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions