feat(webpack-error-notification): definition files (#42517)

- type definitions
- tests

https://github.com/vsolovyov/webpack-error-notification#usage

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-02-20 23:25:05 +01:00 committed by GitHub
parent 14ce63d3bf
commit 0a07cb89a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,30 @@
// Type definitions for webpack-error-notification 0.1
// Project: https://github.com/vsolovyov/webpack-error-notification#readme
// Definitions by: Piotr Błażejewicz (Peter Blazejewicz) <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, Stats } from 'webpack';
declare class WebpackErrorNotificationPlugin extends Plugin {
/**
* You can supply some strategy for the plugin to display notification.
* If you don't supply anything, it will use process.platform as a strategy name.
* `darwin` and `linux` are supported out of the box now.
* You can also supply function(msg) {} as a strategy that will use your notification CLI tool of choice.
*/
constructor(strategy?: WebpackErrorNotificationPlugin.Strategy, options?: WebpackErrorNotificationPlugin.Options);
compileMessage(stats: Stats): string;
compilationDone(stats: Stats): void;
}
declare namespace WebpackErrorNotificationPlugin {
type Strategy = 'darwin' | 'linux' | ((msg: string) => void);
interface Options {
/** if you do not want to notify warnings, set this to `false` */
notifyWarnings?: boolean;
}
}
export = WebpackErrorNotificationPlugin;

View File

@ -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",
"webpack-error-notification-tests.ts"
]
}

View File

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

View File

@ -0,0 +1,43 @@
import WebpackErrorNotificationPlugin = require('webpack-error-notification');
import webpack = require('webpack');
let config: webpack.Configuration = {
plugins: [
// defaults
new WebpackErrorNotificationPlugin(),
],
};
config = {
plugins: [new WebpackErrorNotificationPlugin('darwin')],
};
config = {
plugins: [
new WebpackErrorNotificationPlugin('darwin', {
notifyWarnings: false,
}),
],
};
config = {
plugins: [
new WebpackErrorNotificationPlugin('linux', {
notifyWarnings: false,
}),
],
};
const customStrategy: WebpackErrorNotificationPlugin.Strategy = (msg: string) => {
// todo
};
config = {
plugins: [new WebpackErrorNotificationPlugin(customStrategy)],
};
config = {
plugins: [
new WebpackErrorNotificationPlugin(customStrategy, {
notifyWarnings: false,
}),
],
};