Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.__extends in wrapper-function #2889

Closed
vasa-c opened this issue Apr 23, 2015 · 1 comment
Closed

this.__extends in wrapper-function #2889

vasa-c opened this issue Apr 23, 2015 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@vasa-c
Copy link

vasa-c commented Apr 23, 2015

The code

class A {}

class B extends A {}

Compiled to

var __extends = this.__extends || function (d, b) {
    // ...
};

var A = (function () {
    // ...
})();

var B = (function (_super) {
    // ...
})(A);

Often resulting files can be handled in a specific way.
For example, CommonJS module:

"use strict";

define("moduleName", function (exports, require, module) {
    var __extends = this.__extends || function (d, b) {
        // ...
    };
    var A = (function () {
        // ...
    })();    
    // ...
});

In the strict mode this inside functions is NULL.
this.__extends leads to cannot read property __extends of undefined.

My solution: __extends = (this && this.__extends) || function.
Or delete this.__extends completely (why do we need it?).

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Apr 23, 2015
@RyanCavanaugh
Copy link
Member

Please see #1622 (specifically rbuckton's comment at the bottom)

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants