Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS errors #53

Closed
jagomf opened this issue Mar 12, 2018 · 10 comments
Closed

TS errors #53

jagomf opened this issue Mar 12, 2018 · 10 comments

Comments

@jagomf
Copy link

jagomf commented Mar 12, 2018

I'm getting these errors upon building my project:

../node_modules/@types/webpack/index.d.ts(586,28): error TS2507: Type 'typeof "[...]/node_modules/@types/tapable/index"' is not a constructor function type.
../node_modules/@types/webpack/index.d.ts(628,46): error TS2694: Namespace '"[...]/node_modules/@types/tapable/index"' has no exported member 'Plugin'.
../node_modules/@types/webpack/index.d.ts(632,53): error TS2694: Namespace '"[...]/node_modules/@types/tapable/index"' has no exported member 'Plugin'.
@natablbt
Copy link

I have the same issue.
The same code was ok last friday.

@MaggieAHewitt
Copy link

Same issue w/ Node v9.5.0

@Brunoon
Copy link

Brunoon commented Mar 13, 2018

I change type/webpack to '^3.0.0' and it works.
But the Type definitions for tapable becomes v0.2.5...

@Jesion
Copy link

Jesion commented Mar 13, 2018

npm install @types/tapable --save-dev

solves this issue.

@lukiffer
Copy link

lukiffer commented Mar 21, 2018

This appears to be a result of @types/webpack aggressively getting @types/tapable latest version 1.0.0.

From @types/webpack (2.2.16) package.json:

  "dependencies": {
    "@types/node": "*",
    "@types/tapable": "*",
    "@types/uglify-js": "*"
  },

Which would resolve to semver 1.0.0 according to the list of releases, but as noted above, the "compatible" working version is 0.2.5. When specifying 0.2.5 manually, it works, and the version specification must have been fixed in a more recent version of @types/webpack according to @Brunoon.

dprokop pushed a commit to dprokop/querier-ssr-example that referenced this issue Mar 22, 2018
Ks89 added a commit to Ks89/angular-modal-gallery that referenced this issue Mar 23, 2018
@shallus
Copy link

shallus commented Apr 4, 2018

following up on @Jesion
npm install @types/tapable@0.2.5 --save-dev
fixes the issue

@ooflorent
Copy link
Member

You can use @types/tapable or tapable@2 (when available) to solve the type issues.

@maxrks
Copy link

maxrks commented Nov 28, 2019

@carlosdubus
Copy link

carlosdubus commented Nov 5, 2020

If anyone has wasted an hour on this like me, do the following. This is the only thing that worked for me: add this to your build process to disable typescript check for that file:

sed -i '1s/^/\/\/ @ts-nocheck\n/' node_modules/@types/webpack/index.d.ts

@TomSssM
Copy link

TomSssM commented Sep 1, 2022

The reason this issue happens is that webpack4 is somewhat an old library already and it depends on older version of tapable@1.x.x (and tapable@1.x.x doesn't have its own typings thus there is a ./node_modules/@types/tapable package installed). Most npm packages today depend on newer version of tapable@2.x.x which ships with its own typings. The problem happens when inside @types/webpack (old typings for webpack4) webpack4 imports something from tapable and because we have newer version of tapable installed webpack4 gets its tapable typings not out of the old version (./node_modules/@types/tapable) but from the newer version which has its own typings inside ./node_modules/tapable and the older typings for tapable (./node_modules/@types/tapable) simply get ignored.

The reason solution above works is because when we install very very very old version of @types/tapable@0.2.5 we force npm to move the typings for tapable that webpack4 needs from ./node_modules/@types/tapable into the node_modules of webpack4 making webpack4 pick up the legacy typings for tapable from its own node_modules (./node_modules/@types/webpack/node_modules/@types/tapable) instead of the newer ones from ./node_modules/tapable.

I think a much better solution would be to install the current version of @types/tapable package instead of installing very old and deprecated version, simply run this command:

npm i -D @types/tapable

The effect is going to be absolutely the same except now you get an up-to-date version of the @types/tapable package which, you might have guessed already, simply re-exports the tapable package because nowadays tapable has its own type definitions.

I got this issue when I was installing storybook because storybook still uses webpack4 for some reason. Hopefully in the future they move to webpack5 and this issue disappears altogether.

Thank you, good night

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests