From fe0fce11ec26ef4028ce37fce8d5ec29010da9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Fri, 27 Mar 2020 18:21:49 +0100 Subject: [PATCH] feat(progress-bar-webpack-plugin): new type definition (#43069) - definition file - tests https://github.com/clessg/progress-bar-webpack-plugin#readme https://github.com/clessg/progress-bar-webpack-plugin#options Thanks! --- types/progress-bar-webpack-plugin/index.d.ts | 44 +++++++++++++++++++ .../progress-bar-webpack-plugin-tests.ts | 24 ++++++++++ .../progress-bar-webpack-plugin/tsconfig.json | 23 ++++++++++ types/progress-bar-webpack-plugin/tslint.json | 1 + 4 files changed, 92 insertions(+) create mode 100644 types/progress-bar-webpack-plugin/index.d.ts create mode 100644 types/progress-bar-webpack-plugin/progress-bar-webpack-plugin-tests.ts create mode 100644 types/progress-bar-webpack-plugin/tsconfig.json create mode 100644 types/progress-bar-webpack-plugin/tslint.json diff --git a/types/progress-bar-webpack-plugin/index.d.ts b/types/progress-bar-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..d2b2fed092 --- /dev/null +++ b/types/progress-bar-webpack-plugin/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for progress-bar-webpack-plugin 2.1 +// Project: https://github.com/clessg/progress-bar-webpack-plugin#readme +// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as ProgressBar from 'progress'; +import { Plugin } from 'webpack'; + +export = ProgressBarPlugin; + +declare namespace ProgressBarPlugin { + interface Options extends ProgressBar.ProgressBarOptions { + /** + * the format of the progress bar + * @default ':bar' + */ + format?: string; + /** + * optional function to call when the progress bar completes + */ + callback?: () => void; + /** + * option to show summary of time taken + * @default true + */ + summary?: boolean; + /** + * custom summary message if summary option is false + */ + summaryContent?: boolean; + /** + * function to display a custom summary + * (passed build time) + */ + customSummary?: (summary: string) => void; + } +} + +/** + * A progress bar plugin for Webpack. + */ +declare class ProgressBarPlugin extends Plugin { + constructor(options?: ProgressBarPlugin.Options); +} diff --git a/types/progress-bar-webpack-plugin/progress-bar-webpack-plugin-tests.ts b/types/progress-bar-webpack-plugin/progress-bar-webpack-plugin-tests.ts new file mode 100644 index 0000000000..bb46dc0f61 --- /dev/null +++ b/types/progress-bar-webpack-plugin/progress-bar-webpack-plugin-tests.ts @@ -0,0 +1,24 @@ +import ProgressBarPlugin = require('progress-bar-webpack-plugin'); +import webpack = require('webpack'); + +const configuration: webpack.Configuration = { + plugins: [ + new ProgressBarPlugin({ + total: 10, + format: ` build [:bar] ... (:elapsed seconds)`, + clear: false, + callback: () => { + console.log('done'); + }, + complete: '=', + curr: 2, + incomplete: ' ', + width: 20, + customSummary: summary => { + console.log(summary); + // rest of the code ... + }, + }), + ], +}; +webpack(configuration); diff --git a/types/progress-bar-webpack-plugin/tsconfig.json b/types/progress-bar-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..6e9950d426 --- /dev/null +++ b/types/progress-bar-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", + "progress-bar-webpack-plugin-tests.ts" + ] +} diff --git a/types/progress-bar-webpack-plugin/tslint.json b/types/progress-bar-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/progress-bar-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }