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

express-serve-static-core and serve-static should be an explicit (optional) dependencies if their types are part of export #4467

Closed
wegry opened this issue May 31, 2022 · 4 comments · Fixed by #4468

Comments

@wegry
Copy link
Contributor

wegry commented May 31, 2022

Bug report

Actual Behavior

With Webpack-dev-server@4.9.0, typescript@4.7.2, and yarn@3.2.1

$ yarn tsc

.yarn/__virtual__/webpack-dev-server-virtual-ca9edd4c98/2/.yarn/berry/cache/webpack-dev-server-npm-4.9.0-35850a5f47-8.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3197:18 - error TS2307: Cannot find module 'express-serve-static-core' or its corresponding type declarations.

3197           import("express-serve-static-core").ParamsDictionary,
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

.yarn/__virtual__/webpack-dev-server-virtual-ca9edd4c98/2/.yarn/berry/cache/webpack-dev-server-npm-4.9.0-35850a5f47-8.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3428:18 - error TS2307: Cannot find module 'express-serve-static-core' or its corresponding type declarations.

3428           import("express-serve-static-core").ParamsDictionary,
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

.yarn/__virtual__/webpack-dev-server-virtual-ca9edd4c98/2/.yarn/berry/cache/webpack-dev-server-npm-4.9.0-35850a5f47-8.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3523:34 - error TS2307: Cannot find module 'serve-static' or its corresponding type declarations.

3523 type ServeStaticOptions = import("serve-static").ServeStaticOptions;
                                      ~~~~~~~~~~~~~~

.yarn/__virtual__/webpack-dev-server-virtual-ca9edd4c98/2/.yarn/berry/cache/webpack-dev-server-npm-4.9.0-35850a5f47-8.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3556:14 - error TS2307: Cannot find module 'serve-static' or its corresponding type declarations.

3556     | import("serve-static").ServeStaticOptions<import("http").ServerResponse>
                  ~~~~~~~~~~~~~~

[9:29:45 AM] Found 4 errors. Watching for file changes.

Expected Behavior

tsc should compile without error. @types/express-serve-static-core and @types/serve-static should be an explicit (optional) dependencies if their types are part of export.

How Do We Reproduce?

I'll try and create a repro repo later today.

Please paste the results of npx webpack-cli info here, and mention other relevant information

@wegry wegry changed the title express-serve-static-core and serve-static` should be an explicit (optional) dependencies if their types are part of export express-serve-static-core and serve-static should be an explicit (optional) dependencies if their types are part of export May 31, 2022
@wegry
Copy link
Contributor Author

wegry commented May 31, 2022

Adding

# .yarnrc.yaml
packageExtensions:
  # Missing dependencies that are part of types
  webpack-dev-server@^4.9.0:
    dependencies:
      "@types/express-serve-static-core": '^4.17.18'
      "@types/serve-static": '1.13.0'

Gets me down to

.yarn/__virtual__/webpack-dev-server-virtual-ca9edd4c98/2/.yarn/berry/cache/webpack-dev-server-npm-4.9.0-35850a5f47-8.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3556:7 - error TS2315: Type 'ServeStaticOptions' is not generic.

3556     | import("serve-static").ServeStaticOptions<import("http").ServerResponse>
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[9:47:52 AM] Found 1 error. Watching for file changes.

edit: @types/serve-static@1.13.0 is the correct version for webpack-dev-server@4.9.0. This removes the error.

@alexander-akait
Copy link
Member

We don't use @types/express-serve-static-core directly, so it should not be, but yes serve-static should be in our deps, feel free to send a PR

wegry added a commit to wegry/webpack-dev-server that referenced this issue May 31, 2022
wegry added a commit to wegry/webpack-dev-server that referenced this issue May 31, 2022
@wegry
Copy link
Contributor Author

wegry commented Jun 8, 2022

With #4468,

.yarn/__virtual__/webpack-dev-server-virtual-183572c3b6/0/cache/webpack-dev-server-npm-4.9.2-741b789a9c-201e28445f.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3197:18 - error TS2307: Cannot find module 'express-serve-static-core' or its corresponding type declarations.

3197           import("express-serve-static-core").ParamsDictionary,
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

.yarn/__virtual__/webpack-dev-server-virtual-183572c3b6/0/cache/webpack-dev-server-npm-4.9.2-741b789a9c-201e28445f.zip/node_modules/webpack-dev-server/types/lib/Server.d.ts:3420:18 - error TS2307: Cannot find module 'express-serve-static-core' or its corresponding type declarations.

3420           import("express-serve-static-core").ParamsDictionary,
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is still failing.

@vonagam
Copy link

vonagam commented Mar 6, 2023

Just encountered. So, can @types/express-serve-static-core be added as a dependency or maybe ParamsDictionary import can be replaced with simple { [key: string]: string } (which it is)?

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

Successfully merging a pull request may close this issue.

3 participants