From bb3bc696c16b716a8701ea5df63014dc189ce309 Mon Sep 17 00:00:00 2001 From: Anthony Genson <34021817+AGenson@users.noreply.github.com> Date: Wed, 8 Apr 2020 17:56:05 +0100 Subject: [PATCH] Add types for start-server-webpack-plugin (#43689) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added declarations for start-server-webpack-plugin * Applied standard linting * Update start-server-webpack-plugin - accept string litterals for 'signal' option Co-Authored-By: Piotr Błażejewicz (Peter Blazejewicz) * Update start-server-webpack-plugin - create parameterless constructor suppport Co-Authored-By: Piotr Błażejewicz (Peter Blazejewicz) * Update start-server-webpack-plugin - remove redundant typing of 'apply' method Co-Authored-By: Piotr Błażejewicz (Peter Blazejewicz) * Update start-server-webpack-plugin - remove typescript version as not needed Co-Authored-By: Piotr Błażejewicz (Peter Blazejewicz) * Update start-server-webpack-plugin - combined constructors Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) --- types/start-server-webpack-plugin/index.d.ts | 42 +++++++++++++++++++ .../start-server-webpack-plugin-tests.ts | 20 +++++++++ .../start-server-webpack-plugin/tsconfig.json | 23 ++++++++++ types/start-server-webpack-plugin/tslint.json | 1 + 4 files changed, 86 insertions(+) create mode 100644 types/start-server-webpack-plugin/index.d.ts create mode 100644 types/start-server-webpack-plugin/start-server-webpack-plugin-tests.ts create mode 100644 types/start-server-webpack-plugin/tsconfig.json create mode 100644 types/start-server-webpack-plugin/tslint.json diff --git a/types/start-server-webpack-plugin/index.d.ts b/types/start-server-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..3de14aad79 --- /dev/null +++ b/types/start-server-webpack-plugin/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for start-server-webpack-plugin 2.2 +// Project: https://github.com/ericclemmons/start-server-webpack-plugin +// Definitions by: AGenson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin, Compiler } from 'webpack'; + +export = StartServerWebpackPlugin; + +declare class StartServerWebpackPlugin extends Plugin { + constructor(options?: string | StartServerWebpackPlugin.Options); +} + +declare namespace StartServerWebpackPlugin { + interface Options { + /** + * Name of the server to start (built asset from webpack). + * If not provided, the plugin will tell you the available names. + */ + name?: string; + /** + * Arguments for node. + * Default: `[]`. + */ + nodeArgs?: string[]; + /** + * Arguments for the script. + * Default: `[]`. + */ + args?: string[]; + /** + * Signal to send for HMR. + * Default: 'false'. + */ + signal?: false | true | 'SIGUSR2'; + /** + * Allow typing 'rs' to restart the server. + * Default: 'true' if in 'development' mode, 'false' otherwise. + */ + keyboard?: boolean; + } +} diff --git a/types/start-server-webpack-plugin/start-server-webpack-plugin-tests.ts b/types/start-server-webpack-plugin/start-server-webpack-plugin-tests.ts new file mode 100644 index 0000000000..62bb082c42 --- /dev/null +++ b/types/start-server-webpack-plugin/start-server-webpack-plugin-tests.ts @@ -0,0 +1,20 @@ +import { Configuration } from 'webpack'; +import StartServerWebpackPlugin = require('start-server-webpack-plugin'); + +const c1: Configuration = { + plugins: [ + new StartServerWebpackPlugin('main.js') + ] +}; + +const c2: Configuration = { + plugins: [ + new StartServerWebpackPlugin({ + name: 'main.js', + nodeArgs: [], + args: [], + signal: false, + keyboard: false + }) + ] +}; diff --git a/types/start-server-webpack-plugin/tsconfig.json b/types/start-server-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..d662d6f9c5 --- /dev/null +++ b/types/start-server-webpack-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "start-server-webpack-plugin-tests.ts" + ] +} diff --git a/types/start-server-webpack-plugin/tslint.json b/types/start-server-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/start-server-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }