Every time I attempt to execute typescript in my project, I encounter the following issues:
# ./node_modules/typescript/bin/tsc --project tsconfig.json
node_modules/@types/webpack/index.d.ts:32:3 - error TS2305: Module '"../../tapable/tapable"' does not have an exported member 'Tapable'.
32 Tapable,
~~~~~~~
node_modules/@types/webpack/index.d.ts:1062:23 - error TS2707: Generic type 'SyncWaterfallHook<T, AdditionalOptions>' needs between 1 and 2 type arguments.
1062 resolver: SyncWaterfallHook;
~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1063:22 - error TS2707: Generic type 'SyncWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.
1063 factory: SyncWaterfallHook;
~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1064:28 - error TS2707: Generic type 'AsyncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.
1064 beforeResolve: AsyncSeriesWaterfallHook;
~~~~~~~~~~~~~~~~~~~~~~~~
...and the list goes on with a total of 89 errors.
The initial output line indicates that it is reading types from
./node_modules/tapable/tapable.d.ts
. However, this types file does not export Tapable
; instead, it exports other types like AsyncSeriesWaterfallHook
with specific type parameters. This aligns with the given error message.
Additionally, there exists a file
./node_modules/@types/tapable/index.ts
which indeed exports Tapable
. Upon inspection of some examples, it appears that this types file contains exports with similar names but different type parameters, consistent with webpack's declarations.
In essence, the npm module tapable
seems to have conflicting type definition files: one within its own module and another in the @types/tapable
module. While webpack is designed for the @types
version, it attempts validation against the other variation.
Examining the package.json for webpack (version 5.24.4), we find
"tapable": "^2.1.1"
. Similarly, tapable has "version": "2.1.1"
, indicating they should be compatible.
What could be causing this issue? How can I resolve it to successfully compile?