license-checker-webpack-plugin: Fix outputWriter type (#38579)

The function is passed an object containing a dependencies array, not the array
itself.
This commit is contained in:
Joel Spadin 2019-09-25 13:39:47 -05:00 committed by Michael Crane
parent 62db23a607
commit d84efa6950
2 changed files with 9 additions and 2 deletions

View File

@ -19,6 +19,12 @@ declare namespace LicenseCheckerWebpackPlugin {
licenseText: string;
}
interface OutputWriterArgs {
dependencies: Dependency[];
}
type OutputWriter = (args: OutputWriterArgs) => string;
interface Options {
/**
* Regular expression that matches the file paths of dependencies to check.
@ -59,7 +65,7 @@ declare namespace LicenseCheckerWebpackPlugin {
* 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 | OutputWriter;
/**
* Name of the third-party notices file with all licensing information.

View File

@ -18,7 +18,8 @@ new LicenseCheckerWebpackPlugin({
// $ExpectType LicenseCheckerWebpackPlugin
new LicenseCheckerWebpackPlugin({
filter: /.*/,
outputWriter: (dependencies) => {
outputWriter: ({ dependencies }) => {
dependencies; // $ExpectType Dependency[]
return dependencies.map(d => `${d.name} ${d.licenseName}`).join('\n');
},
});