TypeStrong / fork-ts-checker-webpack-plugin

Webpack plugin that runs typescript type checker on a separate process.
MIT License
1.93k stars 238 forks source link

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

Open sharky98 opened 1 year ago

sharky98 commented 1 year ago

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).

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