Skip to content

In JS, references to class type get static type, not instance type #26877

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
sandersn opened this issue Sep 4, 2018 · 0 comments
Closed

In JS, references to class type get static type, not instance type #26877

sandersn opened this issue Sep 4, 2018 · 0 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@sandersn
Copy link
Member

sandersn commented Sep 4, 2018

Note that this bug depends on the order of the files in the file list. It is very likely in the merge code in the checker. Based on code in chrome-devtools-frontend.

// @Filename: file1.js
var Em = {};
/** @type {number} */
Em.Cee._wrapperInstance;

// @Filename: file2.js
/** @param {Em.Cee} dmv */
function oops(dmv) {
    dmv._model           // should be ok
    // dmv._wrapperInstance // should be error
    new Em.Cee(); // ok?
}
Em.Cee = class {
  constructor() {
    this._model = 111
  }
};

Expected behavior:
Expressions dmv._model and new Em.Cee() should not be errors. dmv._wrapperInstance should be an error.

Actual behavior:
The opposite; "'_model' is not found on 'typeof Em.Cee'" and "Cannot new something that isn't callable or constructable."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

1 participant