Skip to content

importing a class from a CJS package inside ESM package complains "not constructable"Β #47332

Closed
@otakustay

Description

@otakustay

Bug Report

πŸ”Ž Search Terms

class, not constructable, has no construct signatures

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions because it's related to nodenext module

⏯ Playground Link

Playground link with relevant code

Change Module configuration to NodeNext to reproduce errors.

πŸ’» Code

import ESLintPlugin from 'eslint-webpack-plugin';

const plugin = new ESLintPlugin();

πŸ™ Actual behavior

This simple code inside a "type": "module" package with tsconfig.json declaraing "module": "nodenext", "moduleResolution": "nodenext" can result in type errors:

import ESLintPlugin
This expression is not constructable.
  Type 'typeof import("/Users/otakustay/Downloads/s/node_modules/eslint-webpack-plugin/declarations/index")' has no construct signatures.ts(2351)

πŸ™‚ Expected behavior

Since TypeScript already resolves type definition to correct .d.ts, and this type definition seems correct:

export default ESLintWebpackPlugin;
export type Compiler = import('webpack').Compiler;
export type Options = import('./options').Options;
declare class ESLintWebpackPlugin {
  // ...
}

This code should compile as expected.

Metadata

Metadata

Assignees

Labels

ExternalRelates to another program, environment, or user action which we cannot control.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions