Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ const pluginName = "webpack-dev-server";
*/
class Server {
/**
* @param {Configuration<A, S>} options options
* @param {Configuration<A, S> | undefined} options options
* @param {(Compiler | MultiCompiler)=} compiler compiler, omitted when the server is used as a plugin via `apply()`
*/
constructor(options, compiler) {
options ??= {};

Comment thread
Copilot marked this conversation as resolved.
Comment thread
bjohansebas marked this conversation as resolved.
validate(/** @type {Schema} */ (schema), options, {
name: "Dev Server",
baseDataPath: "options",
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ describe("API", () => {
});
});

describe("constructor options", () => {
it("should default `undefined` options to `{}`", async () => {
const compiler = webpack(config);
const server = new Server(undefined, compiler);

expect(server.options).toEqual({});

await server.start();
await server.stop();
});
Comment thread
Copilot marked this conversation as resolved.
Outdated
});

Comment thread
bjohansebas marked this conversation as resolved.
describe("latest async API", () => {
Comment thread
bjohansebas marked this conversation as resolved.
it("should work with async API", async (t) => {
const compiler = webpack(config);
Expand Down
4 changes: 2 additions & 2 deletions types/lib/Server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1495,11 +1495,11 @@ declare class Server<
*/
private static isWebTarget;
/**
* @param {Configuration<A, S>} options options
* @param {Configuration<A, S> | undefined} options options
* @param {(Compiler | MultiCompiler)=} compiler compiler, omitted when the server is used as a plugin via `apply()`
*/
constructor(
options: Configuration<A, S>,
options: Configuration<A, S> | undefined,
compiler?: (Compiler | MultiCompiler) | undefined,
);
compiler:
Expand Down
Loading