Skip to content

Incorrect/overly strong this inference for POJOs #8191

Closed
@chancancode

Description

@chancancode

TypeScript Version:

nightly (1.9.0-dev.20160419)

Code

Ember.Object.extend({
  init() {
    this._super();
//  ^~~~ error TS2339: Property '_super' does not exist on type '{ init(): void; }'.
    ...
  }
});

Expected behavior:

this should be inferred as any

Actual behavior:

this is inferred to be { init(): void; }


This changed somewhere between typescript@1.9.0-dev.20160319 and typescript@1.9.0-dev.20160419. I believe it is unsafe to assume anything about the this on the "methods" on a POJO, as there are several common patterns in JavaScript that breaks this assumption (using POJOs as an "options" or "extensions" dictionary).

Metadata

Metadata

Assignees

Labels

FixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions