From d84efa69501f6be32b12a7e30639decc244e4c6d Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Wed, 25 Sep 2019 13:39:47 -0500 Subject: [PATCH] license-checker-webpack-plugin: Fix outputWriter type (#38579) The function is passed an object containing a dependencies array, not the array itself. --- types/license-checker-webpack-plugin/index.d.ts | 8 +++++++- .../license-checker-webpack-plugin-tests.ts | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/license-checker-webpack-plugin/index.d.ts b/types/license-checker-webpack-plugin/index.d.ts index 3c512a00eb..927a50dfc6 100644 --- a/types/license-checker-webpack-plugin/index.d.ts +++ b/types/license-checker-webpack-plugin/index.d.ts @@ -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. 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 de766de7b3..ea3eac9b91 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 @@ -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'); }, });