Skip to content

TS 2.1.1 appears to be losing prototype for class extending Array. #12193

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

Closed
DeegC opened this issue Nov 12, 2016 · 2 comments
Closed

TS 2.1.1 appears to be losing prototype for class extending Array. #12193

DeegC opened this issue Nov 12, 2016 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@DeegC
Copy link

DeegC commented Nov 12, 2016

TypeScript Version: 2.1.1

The following Typescript line:

this.roots = new EntityArray<EntityInstance>( this.rootEntityName(), this, undefined );

works fine in 2.0.3 but not in 2.1.1. After executing the line the prototype for this.roots should be EntityArray. In 2.1.1 it is just Array. See attached screen shots below. This is causing a problem because a few lines later I call a method defined in EntityArray but I get an error saying the function does not exist:

this.roots.create(initialize, options);

Produces: "this.roots.create is not a function..."

I wasn't able to recreate the error using the playground so I created two branches in my project, one for files generated with 2.0.3 and one generated with 2.1.1. The pertinent file is zeidon.js:

https://github.com/DeegC/UTC/blob/typescript-2.0.3/angular/app/zeidon.js
https://github.com/DeegC/UTC/blob/typescript-2.1.1/angular/app/zeidon.js

There aren't that many differences in the generated .js file so I'm guessing the problem is in how the constructor for EntityArray is generated. Here's the diff for just the constructor:

     __extends(EntityArray, _super);
     function EntityArray(entityName, oi, parentEi) {
-        _super.call(this);
-        this.currentlySelected = 0;
-        this.entityName = entityName;
-        this.oi = oi;
-        this.parentEi = parentEi;
+        var _this = _super.call(this) || this;
+        _this.currentlySelected = 0;
+        _this.entityName = entityName;
+        _this.oi = oi;
+        _this.parentEi = parentEi;
+        return _this;
     }

If necessary I can give instructions for running my app. Let me know if you need any more info.

2.0.3:

typescript2 0 3

2.1.1:

typescript2 1 1

@aluanhaddad
Copy link
Contributor

Duplicate of #11919

@mhegazy
Copy link
Contributor

mhegazy commented Dec 16, 2016

@mhegazy mhegazy closed this as completed Dec 16, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Dec 16, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 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