Skip to content

Fix emit for classes with both fields and 'extends null'#19046

Merged
rbuckton merged 1 commit into
masterfrom
fix15395
Oct 11, 2017
Merged

Fix emit for classes with both fields and 'extends null'#19046
rbuckton merged 1 commit into
masterfrom
fix15395

Conversation

@rbuckton
Copy link
Copy Markdown
Contributor

@rbuckton rbuckton commented Oct 9, 2017

Fixes #15395

@rbuckton rbuckton requested a review from weswigham October 9, 2017 20:15
@weswigham
Copy link
Copy Markdown
Member

To handle a conditional extension of null, shouldn't the regular case emit be updated to _this = _super !== null && _super.apply(this, arguments) || this, too?

@rbuckton
Copy link
Copy Markdown
Contributor Author

@weswigham If you conditionally extend null you can't define a constructor since you can't be certain whether you need to call super. If you have an explicit super we don't emit the conditional _super !== null ... expression.

@rbuckton rbuckton merged commit d08770b into master Oct 11, 2017
@rbuckton rbuckton deleted the fix15395 branch October 11, 2017 18:49
@weswigham
Copy link
Copy Markdown
Member

weswigham commented Oct 11, 2017

Actually, we just already do the right thing:

class Bar {
    constructor() {
        console.log("made");
    }
}

class Foo extends (Math.random() > 0.5 ? null : Bar) {
    x = 2
}

becomes

var Bar = /** @class */ (function () {
    function Bar() {
        console.log("made");
    }
    return Bar;
}());
var Foo = /** @class */ (function (_super) {
    __extends(Foo, _super);
    function Foo() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.x = 2;
        return _this;
    }
    return Foo;
}((Math.random() > 0.5 ? null : Bar)));

Already covered.

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants