Skip to content

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

Closed
@sandersn

Description

@sandersn

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."

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions