vite
vite copied to clipboard
fix: clarify HTTP/2 handler type and sort imports
Description
This PR resolves a lingering TypeScript issue in the HTTP server setup and improves code clarity.
Changes
Main Fix
packages/vite/src/node/http.ts: Replace@ts-expect-error TODOcomment with explicit type cast (as any) and add explanatory comment documenting why this is valid- The Connect middleware app works as an HTTP/1.1 handler
- With
allowHTTP1: true, the HTTP/2 server correctly handles both HTTP/1.1 and HTTP/2 requests - This pattern is intentional and correct
Additional
- Sort imports alphabetically in affected files for consistency with ESLint rules
Motivation
The original @ts-expect-error TODO: is this correct? comment indicated uncertainty about the type handling. This fix:
- Clarifies the intent of the code
- Documents the technical reasoning for maintainability
- Provides clarity for future developers reading the code
Testing
- Code passes
pnpm run lint - Code passes
pnpm run format - No runtime behavior changes
hii @sapphi-red, This PR replaces the @ts-expect-error with an explicit, documented type cast and explains why the HTTP/1.1 handler works correctly in the HTTP/2 server. It also includes minor import sorting. Please review when convenient—thanks!
https://github.com/vitejs/vite/pull/21135#issuecomment-3556411348