Skip to content

Commit 4f481cd

Browse files
committed
fix: overlay filter type definition
1 parent 0c73355 commit 4f481cd

File tree

4 files changed

+95
-18
lines changed

4 files changed

+95
-18
lines changed

client-src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import createSocketURL from "./utils/createSocketURL.js";
1212

1313
/**
1414
* @typedef {Object} OverlayOptions
15-
* @property {boolean | (message: unknown) => boolean} [warnings]
16-
* @property {boolean | (message: unknown) => boolean} [errors]
17-
* @property {boolean | (message: unknown) => boolean} [runtimeErrors]
15+
* @property {boolean | (error: Error) => boolean} [warnings]
16+
* @property {boolean | (error: Error) => boolean} [errors]
17+
* @property {boolean | (error: Error) => boolean} [runtimeErrors]
1818
* @property {string} [trustedTypesPolicyName]
1919
*/
2020

client-src/overlay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function formatProblem(type, item) {
7878
/**
7979
* @typedef {Object} CreateOverlayOptions
8080
* @property {string | null} trustedTypesPolicyName
81-
* @property {boolean | (message: unknown) => void} [catchRuntimeError]
81+
* @property {boolean | (error: Error) => void} [catchRuntimeError]
8282
*/
8383

8484
/**

lib/Server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const schema = require("./options.json");
157157
*/
158158

159159
/**
160-
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
160+
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
161161
*/
162162

163163
/**

types/lib/Server.d.ts

+90-13
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ declare class Server {
136136
* @property {string} [username]
137137
*/
138138
/**
139-
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
139+
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
140140
*/
141141
/**
142142
* @typedef {Object} ClientConfiguration
@@ -316,7 +316,7 @@ declare class Server {
316316
* @property {string} [username]
317317
*/
318318
/**
319-
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
319+
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
320320
*/
321321
/**
322322
* @typedef {Object} ClientConfiguration
@@ -445,7 +445,7 @@ declare class Server {
445445
* @property {string} [username]
446446
*/
447447
/**
448-
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
448+
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
449449
*/
450450
/**
451451
* @typedef {Object} ClientConfiguration
@@ -516,6 +516,41 @@ declare class Server {
516516
type: string;
517517
multiple: boolean;
518518
description: string;
519+
/**
520+
* @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
521+
*/
522+
/**
523+
* @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
524+
*/
525+
/**
526+
* @typedef {Object} Configuration
527+
* @property {boolean | string} [ipc]
528+
* @property {Host} [host]
529+
* @property {Port} [port]
530+
* @property {boolean | "only"} [hot]
531+
* @property {boolean} [liveReload]
532+
* @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
533+
* @property {boolean} [compress]
534+
* @property {boolean} [magicHtml]
535+
* @property {"auto" | "all" | string | string[]} [allowedHosts]
536+
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
537+
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
538+
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
539+
* @property {boolean | string | Static | Array<string | Static>} [static]
540+
* @property {boolean | ServerOptions} [https]
541+
* @property {boolean} [http2]
542+
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
543+
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
544+
* @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
545+
* @property {boolean | string | Open | Array<string | Open>} [open]
546+
* @property {boolean} [setupExitSignals]
547+
* @property {boolean | ClientConfiguration} [client]
548+
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
549+
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
550+
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
551+
* @property {(devServer: Server) => void} [onListening]
552+
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
553+
*/
519554
negatedDescription: string;
520555
path: string;
521556
}
@@ -623,10 +658,6 @@ declare class Server {
623658
)[];
624659
description: string;
625660
multiple: boolean;
626-
/**
627-
* @param {string} URL
628-
* @returns {boolean}
629-
*/
630661
simpleType: string;
631662
};
632663
"client-web-socket-url-username": {
@@ -684,6 +715,11 @@ declare class Server {
684715
simpleType: string;
685716
multiple: boolean;
686717
};
718+
/**
719+
* @param {Port} port
720+
* @param {string} host
721+
* @returns {Promise<number | string>}
722+
*/
687723
hot: {
688724
configs: (
689725
| {
@@ -785,7 +821,6 @@ declare class Server {
785821
multiple: boolean;
786822
};
787823
"https-cert-reset": {
788-
/** @type {string} */
789824
configs: {
790825
description: string;
791826
multiple: boolean;
@@ -981,6 +1016,10 @@ declare class Server {
9811016
description: string;
9821017
simpleType: string;
9831018
multiple: boolean;
1019+
/**
1020+
* @private
1021+
* @returns {Promise<void>}
1022+
*/
9841023
};
9851024
"open-reset": {
9861025
configs: {
@@ -1225,7 +1264,7 @@ declare class Server {
12251264
"static-directory": {
12261265
configs: {
12271266
type: string;
1228-
/** @type {Array<keyof ServerOptions>} */ multiple: boolean;
1267+
multiple: boolean;
12291268
description: string;
12301269
path: string;
12311270
}[];
@@ -1556,7 +1595,7 @@ declare class Server {
15561595
* @property {string} [username]
15571596
*/
15581597
/**
1559-
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
1598+
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
15601599
*/
15611600
/**
15621601
* @typedef {Object} ClientConfiguration
@@ -1716,7 +1755,7 @@ declare class Server {
17161755
* @property {string} [username]
17171756
*/
17181757
/**
1719-
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
1758+
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
17201759
*/
17211760
/**
17221761
* @typedef {Object} ClientConfiguration
@@ -1819,6 +1858,35 @@ declare class Server {
18191858
description: string;
18201859
link: string;
18211860
};
1861+
/**
1862+
* @typedef {Object} Configuration
1863+
* @property {boolean | string} [ipc]
1864+
* @property {Host} [host]
1865+
* @property {Port} [port]
1866+
* @property {boolean | "only"} [hot]
1867+
* @property {boolean} [liveReload]
1868+
* @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
1869+
* @property {boolean} [compress]
1870+
* @property {boolean} [magicHtml]
1871+
* @property {"auto" | "all" | string | string[]} [allowedHosts]
1872+
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
1873+
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
1874+
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
1875+
* @property {boolean | string | Static | Array<string | Static>} [static]
1876+
* @property {boolean | ServerOptions} [https]
1877+
* @property {boolean} [http2]
1878+
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
1879+
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
1880+
* @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
1881+
* @property {boolean | string | Open | Array<string | Open>} [open]
1882+
* @property {boolean} [setupExitSignals]
1883+
* @property {boolean | ClientConfiguration} [client]
1884+
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
1885+
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
1886+
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
1887+
* @property {(devServer: Server) => void} [onListening]
1888+
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
1889+
*/
18221890
ClientWebSocketTransportEnum: {
18231891
enum: string[];
18241892
};
@@ -1940,6 +2008,10 @@ declare class Server {
19402008
ca: {
19412009
anyOf: (
19422010
| {
2011+
/**
2012+
* @param {string} URL
2013+
* @returns {boolean}
2014+
*/
19432015
type: string;
19442016
items: {
19452017
anyOf: (
@@ -2158,6 +2230,7 @@ declare class Server {
21582230
};
21592231
};
21602232
cli: {
2233+
/** @type {ClientConfiguration} */
21612234
exclude: boolean;
21622235
};
21632236
};
@@ -2511,6 +2584,10 @@ declare class Server {
25112584
type?: undefined;
25122585
}
25132586
)[];
2587+
/**
2588+
* @private
2589+
* @returns {Promise<void>}
2590+
*/
25142591
};
25152592
instanceof?: undefined;
25162593
}
@@ -2901,7 +2978,7 @@ declare class Server {
29012978
}
29022979
)[];
29032980
cli: {
2904-
description: string;
2981+
description: string /** @type {Array<keyof ServerOptions>} */;
29052982
} /** @type {Array<keyof ServerOptions>} */;
29062983
};
29072984
WebSocketServerFunction: {
@@ -3592,7 +3669,7 @@ type WebSocketURL = {
35923669
protocol?: string | undefined;
35933670
username?: string | undefined;
35943671
};
3595-
type OverlayMessageOptions = boolean | ((error: unknown) => void);
3672+
type OverlayMessageOptions = boolean | ((error: Error) => void);
35963673
type ClientConfiguration = {
35973674
logging?: "none" | "error" | "warn" | "info" | "log" | "verbose" | undefined;
35983675
overlay?:

0 commit comments

Comments
 (0)