From a2f29ac4a71c1956ebbb1557acb9210c526fea65 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Fri, 29 Mar 2019 02:43:30 -0500 Subject: [PATCH] Improve license-checker-webpack-plugin definitions (#34282) * Add types for license-checker-webpack-plugin * Improve license-checker-webpack-plugin definitions Make options parameter optional. The module documentation does not state whether this parameter is or is not intended to be optional, but the code allows for it. Use Partial instead of interface with all optional fields. --- types/license-checker-webpack-plugin/index.d.ts | 16 ++++++++-------- .../license-checker-webpack-plugin-tests.ts | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/types/license-checker-webpack-plugin/index.d.ts b/types/license-checker-webpack-plugin/index.d.ts index ff131df767..3c512a00eb 100644 --- a/types/license-checker-webpack-plugin/index.d.ts +++ b/types/license-checker-webpack-plugin/index.d.ts @@ -7,7 +7,7 @@ import { Plugin } from 'webpack'; declare class LicenseCheckerWebpackPlugin extends Plugin { - constructor(options: LicenseCheckerWebpackPlugin.Options); + constructor(options?: Partial); } declare namespace LicenseCheckerWebpackPlugin { @@ -23,14 +23,14 @@ declare namespace LicenseCheckerWebpackPlugin { /** * Regular expression that matches the file paths of dependencies to check. */ - filter?: RegExp; + filter: RegExp; /** * SPDX expression with allowed licenses. * * Default: `"(Apache-2.0 OR BSD-2-Clause OR BSD-3-Clause OR MIT)"` */ - allow?: string; + allow: string; /** * Array of dependencies to ignore, in the format `["@"]`. @@ -38,7 +38,7 @@ declare namespace LicenseCheckerWebpackPlugin { * * Default: `[]` */ - ignore?: string[]; + ignore: string[]; /** * Object of dependencies to override, in the format `{"@": { ... }}`. @@ -46,27 +46,27 @@ declare namespace LicenseCheckerWebpackPlugin { * * Default: `{}` */ - override?: Record>; + override: Record>; /** * Whether to emit errors instead of warnings. * * Default: `false` */ - emitError?: boolean; + emitError: boolean; /** * Path to a `.ejs` template, or function that will generate the contents * of the third-party notices file. */ - outputWriter?: string | ((dependencies: Dependency[]) => string); + outputWriter: string | ((dependencies: Dependency[]) => string); /** * Name of the third-party notices file with all licensing information. * * Default: `"ThirdPartyNotices.txt"` */ - outputFilename?: string; + outputFilename: string; } } diff --git a/types/license-checker-webpack-plugin/license-checker-webpack-plugin-tests.ts b/types/license-checker-webpack-plugin/license-checker-webpack-plugin-tests.ts index f476b515f5..de766de7b3 100644 --- a/types/license-checker-webpack-plugin/license-checker-webpack-plugin-tests.ts +++ b/types/license-checker-webpack-plugin/license-checker-webpack-plugin-tests.ts @@ -22,3 +22,6 @@ new LicenseCheckerWebpackPlugin({ return dependencies.map(d => `${d.name} ${d.licenseName}`).join('\n'); }, }); + +// $ExpectType LicenseCheckerWebpackPlugin +new LicenseCheckerWebpackPlugin();