Skip to content

Commit

Permalink
fix: overlay filter type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
malcolm-kee committed Apr 12, 2023
1 parent 0c73355 commit 4f481cd
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 18 deletions.
6 changes: 3 additions & 3 deletions client-src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import createSocketURL from "./utils/createSocketURL.js";

/**
* @typedef {Object} OverlayOptions
* @property {boolean | (message: unknown) => boolean} [warnings]
* @property {boolean | (message: unknown) => boolean} [errors]
* @property {boolean | (message: unknown) => boolean} [runtimeErrors]
* @property {boolean | (error: Error) => boolean} [warnings]
* @property {boolean | (error: Error) => boolean} [errors]
* @property {boolean | (error: Error) => boolean} [runtimeErrors]
* @property {string} [trustedTypesPolicyName]
*/

Expand Down
2 changes: 1 addition & 1 deletion client-src/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function formatProblem(type, item) {
/**
* @typedef {Object} CreateOverlayOptions
* @property {string | null} trustedTypesPolicyName
* @property {boolean | (message: unknown) => void} [catchRuntimeError]
* @property {boolean | (error: Error) => void} [catchRuntimeError]
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const schema = require("./options.json");
*/

/**
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
*/

/**
Expand Down
103 changes: 90 additions & 13 deletions types/lib/Server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ declare class Server {
* @property {string} [username]
*/
/**
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
*/
/**
* @typedef {Object} ClientConfiguration
Expand Down Expand Up @@ -316,7 +316,7 @@ declare class Server {
* @property {string} [username]
*/
/**
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
*/
/**
* @typedef {Object} ClientConfiguration
Expand Down Expand Up @@ -445,7 +445,7 @@ declare class Server {
* @property {string} [username]
*/
/**
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
*/
/**
* @typedef {Object} ClientConfiguration
Expand Down Expand Up @@ -516,6 +516,41 @@ declare class Server {
type: string;
multiple: boolean;
description: string;
/**
* @typedef {Array<{ key: string; value: string }> | Record<string, string | string[]>} Headers
*/
/**
* @typedef {{ name?: string, path?: string, middleware: ExpressRequestHandler | ExpressErrorRequestHandler } | ExpressRequestHandler | ExpressErrorRequestHandler} Middleware
*/
/**
* @typedef {Object} Configuration
* @property {boolean | string} [ipc]
* @property {Host} [host]
* @property {Port} [port]
* @property {boolean | "only"} [hot]
* @property {boolean} [liveReload]
* @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
* @property {boolean} [compress]
* @property {boolean} [magicHtml]
* @property {"auto" | "all" | string | string[]} [allowedHosts]
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
* @property {boolean | string | Static | Array<string | Static>} [static]
* @property {boolean | ServerOptions} [https]
* @property {boolean} [http2]
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
* @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
* @property {boolean | string | Open | Array<string | Open>} [open]
* @property {boolean} [setupExitSignals]
* @property {boolean | ClientConfiguration} [client]
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
* @property {(devServer: Server) => void} [onListening]
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
*/
negatedDescription: string;
path: string;
}
Expand Down Expand Up @@ -623,10 +658,6 @@ declare class Server {
)[];
description: string;
multiple: boolean;
/**
* @param {string} URL
* @returns {boolean}
*/
simpleType: string;
};
"client-web-socket-url-username": {
Expand Down Expand Up @@ -684,6 +715,11 @@ declare class Server {
simpleType: string;
multiple: boolean;
};
/**
* @param {Port} port
* @param {string} host
* @returns {Promise<number | string>}
*/
hot: {
configs: (
| {
Expand Down Expand Up @@ -785,7 +821,6 @@ declare class Server {
multiple: boolean;
};
"https-cert-reset": {
/** @type {string} */
configs: {
description: string;
multiple: boolean;
Expand Down Expand Up @@ -981,6 +1016,10 @@ declare class Server {
description: string;
simpleType: string;
multiple: boolean;
/**
* @private
* @returns {Promise<void>}
*/
};
"open-reset": {
configs: {
Expand Down Expand Up @@ -1225,7 +1264,7 @@ declare class Server {
"static-directory": {
configs: {
type: string;
/** @type {Array<keyof ServerOptions>} */ multiple: boolean;
multiple: boolean;
description: string;
path: string;
}[];
Expand Down Expand Up @@ -1556,7 +1595,7 @@ declare class Server {
* @property {string} [username]
*/
/**
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
*/
/**
* @typedef {Object} ClientConfiguration
Expand Down Expand Up @@ -1716,7 +1755,7 @@ declare class Server {
* @property {string} [username]
*/
/**
* @typedef {boolean | ((error: unknown) => void)} OverlayMessageOptions
* @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions
*/
/**
* @typedef {Object} ClientConfiguration
Expand Down Expand Up @@ -1819,6 +1858,35 @@ declare class Server {
description: string;
link: string;
};
/**
* @typedef {Object} Configuration
* @property {boolean | string} [ipc]
* @property {Host} [host]
* @property {Port} [port]
* @property {boolean | "only"} [hot]
* @property {boolean} [liveReload]
* @property {DevMiddlewareOptions<Request, Response>} [devMiddleware]
* @property {boolean} [compress]
* @property {boolean} [magicHtml]
* @property {"auto" | "all" | string | string[]} [allowedHosts]
* @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback]
* @property {boolean | Record<string, never> | BonjourOptions} [bonjour]
* @property {string | string[] | WatchFiles | Array<string | WatchFiles>} [watchFiles]
* @property {boolean | string | Static | Array<string | Static>} [static]
* @property {boolean | ServerOptions} [https]
* @property {boolean} [http2]
* @property {"http" | "https" | "spdy" | string | ServerConfiguration} [server]
* @property {boolean | "sockjs" | "ws" | string | WebSocketServerConfiguration} [webSocketServer]
* @property {ProxyConfigMap | ProxyConfigArrayItem | ProxyConfigArray} [proxy]
* @property {boolean | string | Open | Array<string | Open>} [open]
* @property {boolean} [setupExitSignals]
* @property {boolean | ClientConfiguration} [client]
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
* @property {(devServer: Server) => void} [onListening]
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
*/
ClientWebSocketTransportEnum: {
enum: string[];
};
Expand Down Expand Up @@ -1940,6 +2008,10 @@ declare class Server {
ca: {
anyOf: (
| {
/**
* @param {string} URL
* @returns {boolean}
*/
type: string;
items: {
anyOf: (
Expand Down Expand Up @@ -2158,6 +2230,7 @@ declare class Server {
};
};
cli: {
/** @type {ClientConfiguration} */
exclude: boolean;
};
};
Expand Down Expand Up @@ -2511,6 +2584,10 @@ declare class Server {
type?: undefined;
}
)[];
/**
* @private
* @returns {Promise<void>}
*/
};
instanceof?: undefined;
}
Expand Down Expand Up @@ -2901,7 +2978,7 @@ declare class Server {
}
)[];
cli: {
description: string;
description: string /** @type {Array<keyof ServerOptions>} */;
} /** @type {Array<keyof ServerOptions>} */;
};
WebSocketServerFunction: {
Expand Down Expand Up @@ -3592,7 +3669,7 @@ type WebSocketURL = {
protocol?: string | undefined;
username?: string | undefined;
};
type OverlayMessageOptions = boolean | ((error: unknown) => void);
type OverlayMessageOptions = boolean | ((error: Error) => void);
type ClientConfiguration = {
logging?: "none" | "error" | "warn" | "info" | "log" | "verbose" | undefined;
overlay?:
Expand Down

0 comments on commit 4f481cd

Please sign in to comment.