Skip to content

Inconvenient typing of 'server' in 'middlewareMode' and 'hmr' #17627

Closed
@emilefokkema

Description

@emilefokkema

Describe the bug

server in the user config option called middlewareMode and server in the hmr options are typed as http.Server. But because the httpServer belonging to the ViteDevServer is typed as something less restrictive, ViteDevServer's own httpServer cannot be used as server in the middlewareMode or hmr options for another vite config. This seems unnecessary, especially since doing so anyway (despite TypeScript's protests) still results in a working config.

I intend to submit a PR for this issue.

Reproduction

https://github.com/emilefokkema/vite-server-type-reproduction

Steps to reproduce

Run npm install followed by npm run typecheck

System Info

System:
    OS: macOS 13.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 1.43 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm
    pnpm: 9.4.0 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 16.6
  npmPackages:
    vite: ^5.3.3 => 5.3.3

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions