diff --git a/client-src/index.js b/client-src/index.js index 4689552d9e..3a948884b5 100644 --- a/client-src/index.js +++ b/client-src/index.js @@ -10,12 +10,20 @@ import sendMessage from "./utils/sendMessage.js"; import reloadApp from "./utils/reloadApp.js"; import createSocketURL from "./utils/createSocketURL.js"; +/** + * @typedef {Object} OverlayOptions + * @property {boolean | (error: Error) => boolean} [warnings] + * @property {boolean | (error: Error) => boolean} [errors] + * @property {boolean | (error: Error) => boolean} [runtimeErrors] + * @property {string} [trustedTypesPolicyName] + */ + /** * @typedef {Object} Options * @property {boolean} hot * @property {boolean} liveReload * @property {boolean} progress - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean, trustedTypesPolicyName?: string }} overlay + * @property {boolean | OverlayOptions} overlay * @property {string} [logging] * @property {number} [reconnect] */ @@ -83,6 +91,23 @@ if (parsedResourceQuery.overlay) { runtimeErrors: true, ...options.overlay, }; + + ["errors", "warnings", "runtimeErrors"].forEach((property) => { + if (typeof options.overlay[property] === "string") { + const overlayFilterFunctionString = decodeURIComponent( + options.overlay[property] + ); + + // eslint-disable-next-line no-new-func + const overlayFilterFunction = new Function( + "message", + `var callback = ${overlayFilterFunctionString} + return callback(message)` + ); + + options.overlay[property] = overlayFilterFunction; + } + }); } enabledFeatures.Overlay = true; } @@ -266,17 +291,24 @@ const onSocketMessage = { log.warn(printableWarnings[i]); } - const needShowOverlayForWarnings = + const overlayWarningsSetting = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.warnings; - if (needShowOverlayForWarnings) { - overlay.send({ - type: "BUILD_ERROR", - level: "warning", - messages: warnings, - }); + if (overlayWarningsSetting) { + const warningsToDisplay = + typeof overlayWarningsSetting === "function" + ? warnings.filter(overlayWarningsSetting) + : warnings; + + if (warningsToDisplay.length) { + overlay.send({ + type: "BUILD_ERROR", + level: "warning", + messages: warnings, + }); + } } if (params && params.preventReloading) { @@ -303,17 +335,24 @@ const onSocketMessage = { log.error(printableErrors[i]); } - const needShowOverlayForErrors = + const overlayErrorsSettings = typeof options.overlay === "boolean" ? options.overlay : options.overlay && options.overlay.errors; - if (needShowOverlayForErrors) { - overlay.send({ - type: "BUILD_ERROR", - level: "error", - messages: errors, - }); + if (overlayErrorsSettings) { + const errorsToDisplay = + typeof overlayErrorsSettings === "function" + ? errors.filter(overlayErrorsSettings) + : errors; + + if (errorsToDisplay.length) { + overlay.send({ + type: "BUILD_ERROR", + level: "error", + messages: errors, + }); + } } }, /** diff --git a/client-src/overlay.js b/client-src/overlay.js index 2887c28ad3..210b4996d1 100644 --- a/client-src/overlay.js +++ b/client-src/overlay.js @@ -78,7 +78,7 @@ function formatProblem(type, item) { /** * @typedef {Object} CreateOverlayOptions * @property {string | null} trustedTypesPolicyName - * @property {boolean} [catchRuntimeError] + * @property {boolean | (error: Error) => void} [catchRuntimeError] */ /** @@ -90,6 +90,8 @@ const createOverlay = (options) => { let iframeContainerElement; /** @type {HTMLDivElement | null | undefined} */ let containerElement; + /** @type {HTMLDivElement | null | undefined} */ + let headerElement; /** @type {Array<(element: HTMLDivElement) => void>} */ let onLoadQueue = []; /** @type {TrustedTypePolicy | undefined} */ @@ -124,6 +126,7 @@ const createOverlay = (options) => { iframeContainerElement.id = "webpack-dev-server-client-overlay"; iframeContainerElement.src = "about:blank"; applyStyle(iframeContainerElement, iframeStyle); + iframeContainerElement.onload = () => { const contentElement = /** @type {Document} */ @@ -141,7 +144,7 @@ const createOverlay = (options) => { contentElement.id = "webpack-dev-server-client-overlay-div"; applyStyle(contentElement, containerStyle); - const headerElement = document.createElement("div"); + headerElement = document.createElement("div"); headerElement.innerText = "Compiled with problems:"; applyStyle(headerElement, headerStyle); @@ -219,9 +222,15 @@ const createOverlay = (options) => { * @param {string} type * @param {Array} messages * @param {string | null} trustedTypesPolicyName + * @param {'build' | 'runtime'} messageSource */ - function show(type, messages, trustedTypesPolicyName) { + function show(type, messages, trustedTypesPolicyName, messageSource) { ensureOverlayExists(() => { + headerElement.innerText = + messageSource === "runtime" + ? "Uncaught runtime errors:" + : "Compiled with problems:"; + messages.forEach((message) => { const entryElement = document.createElement("div"); const msgStyle = @@ -267,8 +276,8 @@ const createOverlay = (options) => { } const overlayService = createOverlayMachine({ - showOverlay: ({ level = "error", messages }) => - show(level, messages, options.trustedTypesPolicyName), + showOverlay: ({ level = "error", messages, messageSource }) => + show(level, messages, options.trustedTypesPolicyName, messageSource), hideOverlay: hide, }); @@ -284,15 +293,22 @@ const createOverlay = (options) => { const errorObject = error instanceof Error ? error : new Error(error || message); - overlayService.send({ - type: "RUNTIME_ERROR", - messages: [ - { - message: errorObject.message, - stack: parseErrorToStacks(errorObject), - }, - ], - }); + const shouldDisplay = + typeof options.catchRuntimeError === "function" + ? options.catchRuntimeError(errorObject) + : true; + + if (shouldDisplay) { + overlayService.send({ + type: "RUNTIME_ERROR", + messages: [ + { + message: errorObject.message, + stack: parseErrorToStacks(errorObject), + }, + ], + }); + } }); } diff --git a/client-src/overlay/state-machine.js b/client-src/overlay/state-machine.js index d9ed764198..4c0444383c 100644 --- a/client-src/overlay/state-machine.js +++ b/client-src/overlay/state-machine.js @@ -4,6 +4,7 @@ import createMachine from "./fsm.js"; * @typedef {Object} ShowOverlayData * @property {'warning' | 'error'} level * @property {Array} messages + * @property {'build' | 'runtime'} messageSource */ /** @@ -23,6 +24,7 @@ const createOverlayMachine = (options) => { context: { level: "error", messages: [], + messageSource: "build", }, states: { hidden: { @@ -73,18 +75,21 @@ const createOverlayMachine = (options) => { return { messages: [], level: "error", + messageSource: "build", }; }, appendMessages: (context, event) => { return { messages: context.messages.concat(event.messages), level: event.level || context.level, + messageSource: event.type === "RUNTIME_ERROR" ? "runtime" : "build", }; }, setMessages: (context, event) => { return { messages: event.messages, level: event.level || context.level, + messageSource: event.type === "RUNTIME_ERROR" ? "runtime" : "build", }; }, hideOverlay, diff --git a/examples/client/overlay/app.js b/examples/client/overlay/app.js index a4344aa340..5885cfaf68 100644 --- a/examples/client/overlay/app.js +++ b/examples/client/overlay/app.js @@ -5,7 +5,15 @@ const createErrorBtn = require("./error-button"); const target = document.querySelector("#target"); -target.insertAdjacentElement("afterend", createErrorBtn()); +target.insertAdjacentElement( + "afterend", + createErrorBtn("Click to throw error", "Error message thrown from JS") +); + +target.insertAdjacentElement( + "afterend", + createErrorBtn("Click to throw ignored error", "something something") +); // eslint-disable-next-line import/no-unresolved, import/extensions const invalid = require("./invalid.js"); diff --git a/examples/client/overlay/error-button.js b/examples/client/overlay/error-button.js index 11fe606af0..2f0b87351e 100644 --- a/examples/client/overlay/error-button.js +++ b/examples/client/overlay/error-button.js @@ -1,18 +1,24 @@ "use strict"; -function unsafeOperation() { - throw new Error("Error message thrown from JS"); -} +/** + * + * @param {string} label + * @param {string} errorMessage + * @returns HTMLButtonElement + */ +module.exports = function createErrorButton(label, errorMessage) { + function unsafeOperation() { + throw new Error(errorMessage); + } -function handleButtonClick() { - unsafeOperation(); -} + function handleButtonClick() { + unsafeOperation(); + } -module.exports = function createErrorButton() { const errorBtn = document.createElement("button"); errorBtn.addEventListener("click", handleButtonClick); - errorBtn.innerHTML = "Click to throw error"; + errorBtn.innerHTML = label; return errorBtn; }; diff --git a/examples/client/overlay/webpack.config.js b/examples/client/overlay/webpack.config.js index 41d8ad543b..a2413a2434 100644 --- a/examples/client/overlay/webpack.config.js +++ b/examples/client/overlay/webpack.config.js @@ -10,7 +10,26 @@ module.exports = setup({ entry: "./app.js", devServer: { client: { - overlay: true, + overlay: { + warnings: false, + runtimeErrors: (msg) => { + if (msg) { + let msgString; + + if (msg instanceof Error) { + msgString = msg.message; + } else if (typeof msg === "string") { + msgString = msg; + } + + if (msgString) { + return !/something/i.test(msgString); + } + } + + return true; + }, + }, }, }, // uncomment to test for IE diff --git a/lib/Server.js b/lib/Server.js index ec3453b6f2..03deff124e 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -154,10 +154,14 @@ const schema = require("./options.json"); * @property {string} [username] */ +/** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ + /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -654,12 +658,28 @@ class Server { } if (typeof client.overlay !== "undefined") { - searchParams.set( - "overlay", + /** + * + * @param {OverlayMessageOptions} [setting] + * @returns + */ + const encodeOverlaySettings = (setting) => + typeof setting === "function" + ? encodeURIComponent(setting.toString()) + : setting; + + const overlayString = typeof client.overlay === "boolean" ? String(client.overlay) - : JSON.stringify(client.overlay) - ); + : JSON.stringify({ + errors: encodeOverlaySettings(client.overlay.errors), + warnings: encodeOverlaySettings(client.overlay.warnings), + runtimeErrors: encodeOverlaySettings( + client.overlay.runtimeErrors + ), + }); + + searchParams.set("overlay", overlayString); } if (typeof client.reconnect !== "undefined") { diff --git a/lib/options.json b/lib/options.json index 87ac7e1fb3..654a68a580 100644 --- a/lib/options.json +++ b/lib/options.json @@ -98,25 +98,49 @@ "additionalProperties": false, "properties": { "errors": { - "description": "Enables a full-screen overlay in the browser when there are compiler errors.", - "type": "boolean", - "cli": { - "negatedDescription": "Disables the full-screen overlay in the browser when there are compiler errors." - } + "anyOf": [ + { + "description": "Enables a full-screen overlay in the browser when there are compiler errors.", + "type": "boolean", + "cli": { + "negatedDescription": "Disables the full-screen overlay in the browser when there are compiler errors." + } + }, + { + "instanceof": "Function", + "description": "Filter compiler errors. Return true to include and return false to exclude." + } + ] }, "warnings": { - "description": "Enables a full-screen overlay in the browser when there are compiler warnings.", - "type": "boolean", - "cli": { - "negatedDescription": "Disables the full-screen overlay in the browser when there are compiler warnings." - } + "anyOf": [ + { + "description": "Enables a full-screen overlay in the browser when there are compiler warnings.", + "type": "boolean", + "cli": { + "negatedDescription": "Disables the full-screen overlay in the browser when there are compiler warnings." + } + }, + { + "instanceof": "Function", + "description": "Filter compiler warnings. Return true to include and return false to exclude." + } + ] }, "runtimeErrors": { - "description": "Enables a full-screen overlay in the browser when there are uncaught runtime errors.", - "type": "boolean", - "cli": { - "negatedDescription": "Disables the full-screen overlay in the browser when there are uncaught runtime errors." - } + "anyOf": [ + { + "description": "Enables a full-screen overlay in the browser when there are uncaught runtime errors.", + "type": "boolean", + "cli": { + "negatedDescription": "Disables the full-screen overlay in the browser when there are uncaught runtime errors." + } + }, + { + "instanceof": "Function", + "description": "Filter uncaught runtime errors. Return true to include and return false to exclude." + } + ] }, "trustedTypesPolicyName": { "description": "The name of a Trusted Types policy for the overlay. Defaults to 'webpack-dev-server#overlay'.", diff --git a/types/lib/Server.d.ts b/types/lib/Server.d.ts index e5ed287917..7361906c51 100644 --- a/types/lib/Server.d.ts +++ b/types/lib/Server.d.ts @@ -139,10 +139,13 @@ declare class Server { * @property {string} [protocol] * @property {string} [username] */ + /** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -294,10 +297,13 @@ declare class Server { * @property {string} [protocol] * @property {string} [username] */ + /** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -454,10 +460,13 @@ declare class Server { * @property {string} [protocol] * @property {string} [username] */ + /** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -550,9 +559,6 @@ declare class Server { simpleType: string; multiple: boolean; }; - /** - * @typedef {Array<{ key: string; value: string }> | Record} Headers - */ "client-reconnect": { configs: ( | { @@ -613,7 +619,7 @@ declare class Server { }[]; description: string; simpleType: string; - multiple: boolean; + /** @type {T} */ multiple: boolean; }; "client-web-socket-url-password": { configs: { @@ -648,20 +654,12 @@ declare class Server { simpleType: string; multiple: boolean; }; - /** - * @private - * @type {RequestHandler[]} - */ "client-web-socket-url-protocol": { configs: ( | { description: string; multiple: boolean; path: string; - /** - * @private - * @type {string | undefined} - */ type: string; values: string[]; } @@ -809,15 +807,16 @@ declare class Server { simpleType: string; multiple: boolean; }; - /** - * @type {string[]} - */ "https-cacert-reset": { + /** + * @private + * @param {Compiler} compiler + */ configs: { description: string; multiple: boolean; path: string; - /** @type {WebSocketURL} */ type: string; + type: string; }[]; description: string; multiple: boolean; @@ -898,7 +897,7 @@ declare class Server { }[]; description: string; simpleType: string; - multiple: boolean; + /** @type {ClientConfiguration} */ multiple: boolean; }; "https-pfx": { configs: { @@ -947,12 +946,6 @@ declare class Server { values: boolean[]; multiple: boolean; description: string; - /** - * prependEntry Method for webpack 4 - * @param {any} originalEntry - * @param {any} newAdditionalEntries - * @returns {any} - */ path: string; } )[]; @@ -995,6 +988,7 @@ declare class Server { | { type: string; multiple: boolean; + /** @type {any} */ description: string; negatedDescription: string; path: string; @@ -1012,7 +1006,7 @@ declare class Server { path: string; }[]; description: string; - simpleType: string; + /** @type {MultiCompiler} */ simpleType: string; multiple: boolean; }; "open-app-name": { @@ -1253,7 +1247,7 @@ declare class Server { type: string; values: string[]; }[]; - /** @type {ServerConfiguration} */ description: string; + description: string; multiple: boolean; simpleType: string; }; @@ -1267,7 +1261,7 @@ declare class Server { } | { type: string; - multiple: boolean; + /** @type {ServerConfiguration} */ multiple: boolean; description: string; negatedDescription: string; path: string; @@ -1286,14 +1280,14 @@ declare class Server { }[]; description: string; simpleType: string; - multiple: boolean; + multiple: boolean /** @type {ServerOptions} */; }; "static-public-path": { configs: { type: string; multiple: boolean; - description: string; - path: string /** @type {any} */; + /** @type {ServerOptions} */ description: string; + path: string; }[]; description: string; simpleType: string; @@ -1610,10 +1604,13 @@ declare class Server { * @property {string} [protocol] * @property {string} [username] */ + /** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -1759,10 +1756,13 @@ declare class Server { * @property {string} [protocol] * @property {string} [username] */ + /** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ /** * @typedef {Object} ClientConfiguration * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] * @property {boolean} [progress] * @property {boolean | number} [reconnect] * @property {"ws" | "sockjs" | string} [webSocketTransport] @@ -1824,25 +1824,158 @@ declare class Server { additionalProperties: boolean; properties: { errors: { - description: string; - type: string; - cli: { - negatedDescription: string; - }; + anyOf: ( + | { + description: string; + type: string; + cli: { + negatedDescription: string; + }; + instanceof?: undefined; + } + | { + instanceof: string; + /** + * @typedef {Object} WebSocketServerConfiguration + * @property {"sockjs" | "ws" | string | Function} [type] + * @property {Record} [options] + */ + /** + * @typedef {(import("ws").WebSocket | import("sockjs").Connection & { send: import("ws").WebSocket["send"], terminate: import("ws").WebSocket["terminate"], ping: import("ws").WebSocket["ping"] }) & { isAlive?: boolean }} ClientConnection + */ + /** + * @typedef {import("ws").WebSocketServer | import("sockjs").Server & { close: import("ws").WebSocketServer["close"] }} WebSocketServer + */ + /** + * @typedef {{ implementation: WebSocketServer, clients: ClientConnection[] }} WebSocketServerImplementation + */ + /** + * @callback ByPass + * @param {Request} req + * @param {Response} res + * @param {ProxyConfigArrayItem} proxyConfig + */ + /** + * @typedef {{ path?: HttpProxyMiddlewareOptionsFilter | undefined, context?: HttpProxyMiddlewareOptionsFilter | undefined } & { bypass?: ByPass } & HttpProxyMiddlewareOptions } ProxyConfigArrayItem + */ + /** + * @typedef {(ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[]} ProxyConfigArray + */ + /** + * @typedef {{ [url: string]: string | ProxyConfigArrayItem }} ProxyConfigMap + */ + /** + * @typedef {Object} OpenApp + * @property {string} [name] + * @property {string[]} [arguments] + */ + /** + * @typedef {Object} Open + * @property {string | string[] | OpenApp} [app] + * @property {string | string[]} [target] + */ + /** + * @typedef {Object} NormalizedOpen + * @property {string} target + * @property {import("open").Options} options + */ + /** + * @typedef {Object} WebSocketURL + * @property {string} [hostname] + * @property {string} [password] + * @property {string} [pathname] + * @property {number | string} [port] + * @property {string} [protocol] + * @property {string} [username] + */ + /** + * @typedef {boolean | ((error: Error) => void)} OverlayMessageOptions + */ + /** + * @typedef {Object} ClientConfiguration + * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] + * @property {boolean | { warnings?: OverlayMessageOptions, errors?: OverlayMessageOptions, runtimeErrors?: OverlayMessageOptions }} [overlay] + * @property {boolean} [progress] + * @property {boolean | number} [reconnect] + * @property {"ws" | "sockjs" | string} [webSocketTransport] + * @property {string | WebSocketURL} [webSocketURL] + */ + /** + * @typedef {Array<{ key: string; value: string }> | Record} 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} [devMiddleware] + * @property {boolean} [compress] + * @property {boolean} [magicHtml] + * @property {"auto" | "all" | string | string[]} [allowedHosts] + * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] + * @property {boolean | Record | BonjourOptions} [bonjour] + * @property {string | string[] | WatchFiles | Array} [watchFiles] + * @property {boolean | string | Static | Array} [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} [open] + * @property {boolean} [setupExitSignals] + * @property {boolean | ClientConfiguration} [client] + * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] + * @property {(devServer: Server) => void} [onAfterSetupMiddleware] + * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] + * @property {(devServer: Server) => void} [onListening] + * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] + */ + description: string; + type?: undefined; + cli?: undefined; + } + )[]; }; warnings: { - description: string; - type: string; - cli: { - negatedDescription: string; - }; + anyOf: ( + | { + description: string; + type: string; + cli: { + negatedDescription: string; + }; + instanceof?: undefined; + } + | { + instanceof: string; + description: string; + type?: undefined; + cli?: undefined; + } + )[]; }; runtimeErrors: { - description: string; - type: string; - cli: { - negatedDescription: string; - }; + anyOf: ( + | { + description: string; + type: string; + cli: { + negatedDescription: string; + }; + instanceof?: undefined; + } + | { + instanceof: string; + description: string; + type?: undefined; + cli?: undefined; + } + )[]; }; trustedTypesPolicyName: { description: string; @@ -1869,69 +2002,6 @@ declare class Server { anyOf: ( | { type: string; - /** - * @typedef {Object} Open - * @property {string | string[] | OpenApp} [app] - * @property {string | string[]} [target] - */ - /** - * @typedef {Object} NormalizedOpen - * @property {string} target - * @property {import("open").Options} options - */ - /** - * @typedef {Object} WebSocketURL - * @property {string} [hostname] - * @property {string} [password] - * @property {string} [pathname] - * @property {number | string} [port] - * @property {string} [protocol] - * @property {string} [username] - */ - /** - * @typedef {Object} ClientConfiguration - * @property {"log" | "info" | "warn" | "error" | "none" | "verbose"} [logging] - * @property {boolean | { warnings?: boolean, errors?: boolean, runtimeErrors?: boolean }} [overlay] - * @property {boolean} [progress] - * @property {boolean | number} [reconnect] - * @property {"ws" | "sockjs" | string} [webSocketTransport] - * @property {string | WebSocketURL} [webSocketURL] - */ - /** - * @typedef {Array<{ key: string; value: string }> | Record} 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} [devMiddleware] - * @property {boolean} [compress] - * @property {boolean} [magicHtml] - * @property {"auto" | "all" | string | string[]} [allowedHosts] - * @property {boolean | ConnectHistoryApiFallbackOptions} [historyApiFallback] - * @property {boolean | Record | BonjourOptions} [bonjour] - * @property {string | string[] | WatchFiles | Array} [watchFiles] - * @property {boolean | string | Static | Array} [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} [open] - * @property {boolean} [setupExitSignals] - * @property {boolean | ClientConfiguration} [client] - * @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext) => Headers)} [headers] - * @property {(devServer: Server) => void} [onAfterSetupMiddleware] - * @property {(devServer: Server) => void} [onBeforeSetupMiddleware] - * @property {(devServer: Server) => void} [onListening] - * @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares] - */ cli: { negatedDescription: string; }; @@ -2056,6 +2126,10 @@ declare class Server { } | { type: string; + /** + * @private + * @type {{ name: string | symbol, listener: (...args: any[]) => void}[] }} + */ additionalProperties: boolean; properties: { passphrase: { @@ -2395,7 +2469,7 @@ declare class Server { cli: { negatedDescription: string; }; - link: string; + link: string /** @type {number | string} */; }; MagicHTML: { type: string; @@ -2433,7 +2507,7 @@ declare class Server { } | { $ref: string; - /** @type {string} */ type?: undefined; + type?: undefined; items?: undefined; } )[]; @@ -2532,6 +2606,12 @@ declare class Server { | { type: string; minLength: number; + /** + * prependEntry Method for webpack 4 + * @param {any} originalEntry + * @param {any} newAdditionalEntries + * @returns {any} + */ minimum?: undefined; maximum?: undefined; enum?: undefined; @@ -2570,7 +2650,7 @@ declare class Server { } )[]; description: string; - /** @type {Object} */ link: string; + link: string; }; Server: { anyOf: { @@ -2603,11 +2683,12 @@ declare class Server { $ref: string; }[]; }; + /** @type {MultiCompiler} */ options: { $ref: string; }; }; - additionalProperties: boolean; + /** @type {MultiCompiler} */ additionalProperties: boolean; }; ServerOptions: { type: string; @@ -2615,7 +2696,7 @@ declare class Server { properties: { passphrase: { type: string; - description: string; + /** @type {MultiCompiler} */ description: string; }; requestCert: { type: string; @@ -2663,6 +2744,10 @@ declare class Server { anyOf: ( | { type: string; + /** + * @private + * @returns {Promise} + */ instanceof?: undefined; } | { @@ -2684,6 +2769,10 @@ declare class Server { items?: undefined; } )[]; + /** + * @param {WatchOptions & { aggregateTimeout?: number, ignored?: WatchOptions["ignored"], poll?: number | boolean }} watchOptions + * @returns {WatchOptions} + */ description: string; }; cert: { @@ -3051,7 +3140,7 @@ declare class Server { }; }; }; - additionalProperties: boolean; + /** @type {ServerOptions} */ additionalProperties: boolean; }; WebSocketServerString: { type: string; @@ -3059,7 +3148,6 @@ declare class Server { }; }; additionalProperties: boolean; - /** @type {ServerOptions} */ properties: { allowedHosts: { $ref: string; @@ -3121,7 +3209,6 @@ declare class Server { proxy: { $ref: string; }; - /** @type {any} */ server: { $ref: string; }; @@ -3502,6 +3589,7 @@ declare namespace Server { Open, NormalizedOpen, WebSocketURL, + OverlayMessageOptions, ClientConfiguration, Headers, Middleware, @@ -3720,14 +3808,15 @@ type WebSocketURL = { protocol?: string | undefined; username?: string | undefined; }; +type OverlayMessageOptions = boolean | ((error: Error) => void); type ClientConfiguration = { logging?: "none" | "error" | "warn" | "info" | "log" | "verbose" | undefined; overlay?: | boolean | { - warnings?: boolean | undefined; - errors?: boolean | undefined; - runtimeErrors?: boolean | undefined; + warnings?: OverlayMessageOptions | undefined; + errors?: OverlayMessageOptions | undefined; + runtimeErrors?: OverlayMessageOptions | undefined; } | undefined; progress?: boolean | undefined;