Skip to content

In JS, imported class type references resolve to static, not instance type. #34671

Closed
@sandersn

Description

@sandersn
// @filename: first.js
class C {
  s() { }
}
module.exports.C = C
// @filename: test.js
/** @typedef {import('./first').C} C */
/** @param {C} c */
function demo(c) {
  c.s
}

Expected: no error and c.s: () => {}.

Actual: Property 's' does not exist on 'typeof C'.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions