Skip to content
New issue

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

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

Already on GitHub? # to your account

Bug in transpiled __extend code ? #4293

Closed
vjau opened this issue Aug 12, 2015 · 4 comments
Closed

Bug in transpiled __extend code ? #4293

vjau opened this issue Aug 12, 2015 · 4 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@vjau
Copy link

vjau commented Aug 12, 2015

I have a problem with some code produced by typescript.

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

I get the following error when run under node :

 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype,
                                                                   ^
TypeError: Cannot read property 'prototype' of undefined
    at __extends (/home/vincent/dev/codingame/heatdetector/code.js:4:68)
    at /home/vincent/dev/codingame/heatdetector/code.js:113:5
    at Object.<anonymous> (/home/vincent/dev/codingame/heatdetector/code.js:162:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

The only calling code of __extends in the transpiled code is this:

var Move = (function (_super) {
    __extends(Move, _super);
    function Move(param1, param2) {
        if (param1 && param1.x && param2 && param2.x) {
            _super.call(this, param1, param2);
        }
        if (typeof param1 === "number" && typeof param2 === "number") {
            _super.call(this, param1, param2);
        }
        if (typeof param1 === "number" && param2 && param2.x) {
            _super.call(this, param1, param2);
        }
    }

Problem present both in 1.5.3 and in 1.6.0-dev.20150812 nigthly
I can give you more information and try to do a minimal repro if you need it.

Thank you.

@adidahiya
Copy link
Contributor

Your super class hasn't been defined at that point in the code yet. Check that the order of your scripts is correct.

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Aug 12, 2015
@mhegazy mhegazy closed this as completed Aug 12, 2015
@vjau
Copy link
Author

vjau commented Aug 13, 2015

You are right, but how comes the compiler doesn't warn me about that ?

@DanielRosenwasser
Copy link
Member

@vjau we're tracking this in #2854

@kodeine
Copy link

kodeine commented Feb 26, 2017

i am getting the same problem.
Uncaught TypeError: Cannot read property 'prototype' of undefined

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

5 participants