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

Exported class with a parent, decorator and self-referential static properties fails at runtime with "Object.setPrototypeOf called on null or undefined" #16506

Closed
guncha opened this issue Jun 13, 2017 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@guncha
Copy link

guncha commented Jun 13, 2017

TypeScript Version: 2.5.0-dev.20170613

Code

class Foo {}

@bar
export class Bar extends Foo {
  static FOO = 321
  static BAR = Bar.FOO
}

function bar(x) {
  return x
}

Expected behavior:

Should compile and run.

Actual behavior:

With target ES5, this compiles into:

// helpers omitted
Object.defineProperty(exports, "__esModule", { value: true });
var Foo = (function () {
    function Foo() {
    }
    return Foo;
}());
var Bar = (function (_super) {
    __extends(Bar, _super);
    var Bar = Bar_1 = function Bar() {
        return _super !== null && _super.apply(this, arguments) || this;
    };
    Bar.FOO = 321;
    Bar.BAR = Bar_1.FOO;
    Bar = Bar_1 = __decorate([
        bar
    ], Bar);
    return Bar;
    var Bar_1;
}(Foo));
exports.Bar = Bar;
function bar(x) {
    return x;
}

And fails at runtime with Object.setPrototypeOf called on null or undefined in the __extends helper.

Compiled with 2.3.4:

// helpers omitted
Object.defineProperty(exports, "__esModule", { value: true });
var Foo = (function () {
    function Foo() {
    }
    return Foo;
}());
var Bar = Bar_1 = (function (_super) {
    __extends(Bar, _super);
    function Bar() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Bar;
}(Foo));
Bar.FOO = 321;
Bar.BAR = Bar_1.FOO;
Bar = Bar_1 = __decorate([
    bar
], Bar);
exports.Bar = Bar;
function bar(x) {
    return x;
}
var Bar_1;
@mhegazy mhegazy added the Duplicate An existing issue was already created label Jun 13, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Jun 13, 2017

Duplicate of #16417, fixed by #16496. Fix should be in typescript@next later tonight and typescript@2.4.1 in two weeks.

@fletchsod-developer
Copy link

Just came upon this via Google Search. Shouldn't this issue be closed cuz it's a duplicate of #14617 ?

@mhegazy
Copy link
Contributor

mhegazy commented Aug 17, 2017

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy mhegazy closed this as completed Aug 17, 2017
@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
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants