fix(types)!: expose httpServer with Http2SecureServer union#14834
fix(types)!: expose httpServer with Http2SecureServer union#14834patak-cat merged 3 commits intovitejs:mainfrom
Conversation
|
|
|
This will affect downstream plugins and projects that access the |
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI on
|
There was a problem hiding this comment.
I think we can give this a try. It also looks like we attempted this in the past (#10196) but reverted as it's breaking downstream. Now in the Vite 5 beta would be a good time to go with this.
EDIT: oh it looks like there's merge conflicts
HttpServer type to avoid type assertion
Looks like new added AsyncDisposable conflicts with this, I've resolved this conflict. |
Description
The
http.ServerandHttp2SecureServertypes were previously asserted to HttpServer directly. This meant that some properties were potentially unusable:vite/packages/vite/src/node/http.ts
Lines 108 to 118 in 9866be0
This PR explicitly declare a
HttpServertype as the union of the two server types. These two types share a large common property - only a small subset of properties are unavailable when using the unionHttpServertype.vite/packages/vite/src/node/server/index.ts
Line 185 in 3db374a
This makes property usage more strict and avoids impossible states when using the two server types interchangeably.
Additional context
Some properties are now inaccessible when using
HttpServer:http.Server only:
Http2SecureServer only:
However, none of these properties were used in the current code. So the behavior impact of this type change is theoretically none.
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).