Skip to content

In JS, commonjs require imports typeof class, not class instance type. #40155

Closed
@sandersn

Description

@sandersn

From the webpack user test:

// @filename: mod1.js
class K {
	values() {
	}
}
exports.K = K;
// @filename: test.js
const { K } = require("./mod1");
/** @type {K} */
let k;
k.values();

Expected behavior:

No error, and k: K

Actual behavior:

Error "'values' not found on 'typeof K'." and k: typeof K.

Note: doesn't happen with exports.K = class { values() {} }

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