Skip to content

TS Typing error: "This expression is not constructable." when esModuleInterop is false #65

@fcaminada

Description

@fcaminada

Bug Report

Hello, I am opening this issue as an follow-up to #16, which I believe still has issues with the TypeScript typing.
As I mentioned on my comment, it is not possible to correctly import this package with its current type exports if I use the esModuleInterop set as false.

  • Operating System:
  • Node Version: v14.15.1
  • NPM Version: 7.0.14
  • webpack Version: 5.11.0
  • eslint-webpack-plugin Version: 2.4.0
  • eslint version: 7.7.0
  • Typescript version: 4.0.1

Expected Behavior

Importing "eslint-webpack-plugin" should correctly return the ESLintWebpackPlugin class and I should be able to instantiate it with the following code;

import ESLintWebpackPlugin = require("eslint-webpack-plugin");
import * as ESLintWebpackPlugin from "eslint-webpack-plugin"; // Alternative import.
import ESLintWebpackPlugin from "eslint-webpack-plugin" // when using esModuleInterop: true
...
new ESLintWebpackPlugin({
    // Options.
});

Actual Behavior

Importing the default exports causes either a TS or a JS error when esModuleInterop is disabled, as I better explain on my comment here.

Code and Reproduction:

https://gist.github.com/fcaminada/7d2cc25c74c3b7bdfe43246190c5d57d

The solution would be to follow the same example as other plugins such as CssMinimizerPlugin, for instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions