fork-ts-checker-webpack-plugin icon indicating copy to clipboard operation
fork-ts-checker-webpack-plugin copied to clipboard

Issues when importing plugin in TypeScript (`index.d.ts` vs `plugin.d.ts`)

Open sharky98 opened this issue 1 year ago • 0 comments

Current behavior

I am using TypeScript to write some default configurations. When I import with import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";, the line const forkTypeCheckingPlugin = new ForkTsCheckerWebpackPlugin() is showing me some eslint issues from my IDE (using tsconfig.esm.json from the gist below).

  • new is shown as being ESLint: Unsafe construction of an any type value.(@typescript-eslint/no-unsafe-call)
  • forkTypeCheckingPlugin is shown as being ESLint: Unsafe assignment of an any value.(@typescript-eslint/no-unsafe-assignment)

When compiling with TSC, I get Module [fork-ts-checker-webpack-plugin] can only be default-imported using the 'esModuleInterop' flag (using tsconfig.cjs.json from the gist below).

When I import using import { ForkTsCheckerWebpackPlugin } from "fork-ts-checker-webpack-plugin/lib/plugin.js"; I have no more issues.

Expected behavior

No issues shown either on IDE or tsc when using the import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin"; import statement when creating TypeScript package, using the most recent versions and configurations (TS 5, module resolution node16, etc.).

⚠ It might be a misconfiguration on my side for the IDE, even though I would prefer to no change any behavioral configuration such as esModuleInterop or verbatimModuleSyntax.

Steps to reproduce the issue

Using configuration shown in gist below,

  1. Import using import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";.
  2. Create instance using const forkTypeCheckingPlugin = new ForkTsCheckerWebpackPlugin().

Issue reproduction repository

https://gist.github.com/sharky98/94ac3a661e2862c5df5108152a00efd4

Environment

  • fork-ts-checker-webpack-plugin: ^8.0.0
  • typescript: ^5.0.4
  • eslint: ^8.41.0
  • webpack: ^5.84.0
  • os: Windows 10

sharky98 avatar Jun 01 '23 15:06 sharky98