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<Options> instead of interface with all optional fields.
This commit is contained in:
Joel Spadin
2019-03-29 02:43:30 -05:00
committed by Ron Buckton
parent cd3f215693
commit a2f29ac4a7
2 changed files with 11 additions and 8 deletions

View File

@@ -7,7 +7,7 @@
import { Plugin } from 'webpack';
declare class LicenseCheckerWebpackPlugin extends Plugin {
constructor(options: LicenseCheckerWebpackPlugin.Options);
constructor(options?: Partial<LicenseCheckerWebpackPlugin.Options>);
}
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 `["<dependency name>@<version range>"]`.
@@ -38,7 +38,7 @@ declare namespace LicenseCheckerWebpackPlugin {
*
* Default: `[]`
*/
ignore?: string[];
ignore: string[];
/**
* Object of dependencies to override, in the format `{"<dependency name>@<version range>": { ... }}`.
@@ -46,27 +46,27 @@ declare namespace LicenseCheckerWebpackPlugin {
*
* Default: `{}`
*/
override?: Record<string, Partial<Dependency>>;
override: Record<string, Partial<Dependency>>;
/**
* 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;
}
}

View File

@@ -22,3 +22,6 @@ new LicenseCheckerWebpackPlugin({
return dependencies.map(d => `${d.name} ${d.licenseName}`).join('\n');
},
});
// $ExpectType LicenseCheckerWebpackPlugin
new LicenseCheckerWebpackPlugin();