From 23b6d9f1ef4dd9830f45aa8e7227aa352f757b4e Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Fri, 16 Aug 2024 15:42:33 +0300 Subject: [PATCH] refactor: ts --- types/lib/Server.d.ts | 140 ++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 67 deletions(-) diff --git a/types/lib/Server.d.ts b/types/lib/Server.d.ts index e52b2e5276..05e3aec532 100644 --- a/types/lib/Server.d.ts +++ b/types/lib/Server.d.ts @@ -5,11 +5,11 @@ export = Server; */ /** * @template {BasicApplication} [A=ExpressApplication] - * @template {import("http").Server} [S=import("http").Server] + * @template {BasicServer} [S=HTTPServer] */ declare class Server< A extends BasicApplication = import("express").Application, - S extends import("http").Server = import("http").Server< + S extends BasicServer = import("http").Server< typeof import("http").IncomingMessage, typeof import("http").ServerResponse >, @@ -1165,11 +1165,11 @@ declare class Server< */ private static isWebTarget; /** - * @param {Configuration} options + * @param {Configuration} options * @param {Compiler | MultiCompiler} compiler */ constructor( - options: Configuration | undefined, + options: Configuration | undefined, compiler: Compiler | MultiCompiler, ); compiler: import("webpack").Compiler | import("webpack").MultiCompiler; @@ -1177,7 +1177,7 @@ declare class Server< * @type {ReturnType} * */ logger: ReturnType; - options: Configuration; + options: Configuration; /** * @type {FSWatcher[]} */ @@ -1222,8 +1222,9 @@ declare class Server< */ private getClientTransport; /** + * @template T * @private - * @returns {string} + * @returns {T} */ private getServerTransport; /** @@ -1431,6 +1432,7 @@ declare namespace Server { IPv4, IPv6, Socket, + HTTPServer, IncomingMessage, ServerResponse, OpenOptions, @@ -1472,6 +1474,7 @@ declare namespace Server { Headers, MiddlewareHandler, Middleware, + BasicServer, Configuration, BasicApplication, }; @@ -1502,6 +1505,7 @@ type ServeStaticOptions = import("serve-static").ServeStaticOptions; type IPv4 = import("ipaddr.js").IPv4; type IPv6 = import("ipaddr.js").IPv6; type Socket = import("net").Socket; +type HTTPServer = import("http").Server; type IncomingMessage = import("http").IncomingMessage; type ServerResponse = import("http").ServerResponse; type OpenOptions = import("open").Options; @@ -1686,67 +1690,69 @@ type Middleware = middleware: MiddlewareHandler; } | MiddlewareHandler; -type Configuration = - { - ipc?: string | boolean | undefined; - host?: string | undefined; - port?: Port | undefined; - hot?: boolean | "only" | undefined; - liveReload?: boolean | undefined; - devMiddleware?: - | DevMiddlewareOptions< - import("express").Request< - import("express-serve-static-core").ParamsDictionary, - any, - any, - qs.ParsedQs, - Record - >, - import("express").Response> - > - | undefined; - compress?: boolean | undefined; - allowedHosts?: string | string[] | undefined; - historyApiFallback?: - | boolean - | import("connect-history-api-fallback").Options - | undefined; - bonjour?: - | boolean - | Record - | import("bonjour-service").Service - | undefined; - watchFiles?: - | string - | string[] - | WatchFiles - | (string | WatchFiles)[] - | undefined; - static?: string | boolean | Static | (string | Static)[] | undefined; - server?: string | ServerConfiguration | undefined; - app?: (() => Promise) | undefined; - webSocketServer?: - | string - | boolean - | WebSocketServerConfiguration - | undefined; - proxy?: ProxyConfigArray | undefined; - open?: string | boolean | Open | (string | Open)[] | undefined; - setupExitSignals?: boolean | undefined; - client?: boolean | ClientConfiguration | undefined; - headers?: - | Headers - | (( - req: Request, - res: Response, - context: DevMiddlewareContext, - ) => Headers) - | undefined; - onListening?: ((devServer: Server) => void) | undefined; - setupMiddlewares?: - | ((middlewares: Middleware[], devServer: Server) => Middleware[]) - | undefined; - }; +type BasicServer = import("net").Server; +type Configuration< + A extends BasicApplication = import("express").Application, + S extends BasicServer = import("http").Server< + typeof import("http").IncomingMessage, + typeof import("http").ServerResponse + >, +> = { + ipc?: string | boolean | undefined; + host?: string | undefined; + port?: Port | undefined; + hot?: boolean | "only" | undefined; + liveReload?: boolean | undefined; + devMiddleware?: + | DevMiddlewareOptions< + import("express").Request< + import("express-serve-static-core").ParamsDictionary, + any, + any, + qs.ParsedQs, + Record + >, + import("express").Response> + > + | undefined; + compress?: boolean | undefined; + allowedHosts?: string | string[] | undefined; + historyApiFallback?: + | boolean + | import("connect-history-api-fallback").Options + | undefined; + bonjour?: + | boolean + | Record + | import("bonjour-service").Service + | undefined; + watchFiles?: + | string + | string[] + | WatchFiles + | (string | WatchFiles)[] + | undefined; + static?: string | boolean | Static | (string | Static)[] | undefined; + server?: string | ServerConfiguration | undefined; + app?: (() => Promise) | undefined; + webSocketServer?: string | boolean | WebSocketServerConfiguration | undefined; + proxy?: ProxyConfigArray | undefined; + open?: string | boolean | Open | (string | Open)[] | undefined; + setupExitSignals?: boolean | undefined; + client?: boolean | ClientConfiguration | undefined; + headers?: + | Headers + | (( + req: Request, + res: Response, + context: DevMiddlewareContext, + ) => Headers) + | undefined; + onListening?: ((devServer: Server) => void) | undefined; + setupMiddlewares?: + | ((middlewares: Middleware[], devServer: Server) => Middleware[]) + | undefined; +}; type BasicApplication = { use: typeof useFn; };