Add typings for webpackbar

This commit is contained in:
Ryan Clark 2018-06-01 19:12:39 +01:00
parent 9fb3214e64
commit 6249fa61e2
4 changed files with 94 additions and 0 deletions

61
types/webpackbar/index.d.ts vendored Normal file
View File

@ -0,0 +1,61 @@
// Type definitions for webpackbar 2.6
// Project: https://github.com/nuxt/webpackbar
// Definitions by: Ryan Clark <https://github.com/rynclark>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
import { Plugin } from 'webpack';
export = WebpackBar;
declare class WebpackBar extends Plugin {
constructor(options?: WebpackBar.Options);
state: WebpackBar.State;
}
declare namespace WebpackBar {
interface Stats {
count: number;
time: [number, number];
}
class Profile {
requests: any[];
name: string;
constructor(name: string);
getStats(): { ext: Stats, loader: Stats };
}
interface State {
isRunning: boolean;
color: string;
profile: Profile | null;
}
interface SharedState {
[name: string]: State;
}
interface Options {
/** Display name */
name?: string;
/** Color output of the progress bar */
color?: string;
/** Enable the profiler for files and loaders */
profile?: boolean;
/** Stream to rwite to */
stream?: NodeJS.WriteStream;
/** Minimal output */
minimal?: boolean;
/** Show compiled in time */
compiledIn?: boolean;
/** Function called when all builds are finished */
done?: (sharedState: SharedState, ctx: WebpackBar) => void;
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webpackbar-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,9 @@
import WebpackBar = require('webpackbar');
new WebpackBar();
new WebpackBar({ color: '#ff0000' });
new WebpackBar({ stream: process.stdout });
new WebpackBar({ done: (sharedState, ctx) => {} });