add worker-plugin types (#41223)

This commit is contained in:
Artur Androsovych
2019-12-27 09:36:57 -06:00
committed by Andrew Branch
parent a9fd0c12aa
commit 97f91edc4d
4 changed files with 69 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for worker-plugin 3.2
// Project: https://github.com/GoogleChromeLabs/worker-plugin
// Definitions by: Artur Androsovych <https://github.com/arturovt>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as webpack from 'webpack';
export = WorkerPlugin;
declare class WorkerPlugin extends webpack.Plugin {
constructor(options?: WorkerPlugin.Options);
}
declare namespace WorkerPlugin {
interface Options {
globalObject?: boolean | string;
plugins?: Array<string | webpack.Plugin>;
}
}
+23
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",
"worker-plugin-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
@@ -0,0 +1,23 @@
import WorkerPlugin = require('worker-plugin');
import webpack = require('webpack');
new WorkerPlugin();
class ExistingPlugin extends webpack.Plugin {}
const optionsArray: WorkerPlugin.Options[] = [
{
globalObject: false,
},
{
globalObject: 'self',
},
{
plugins: [
'SomeExistingPlugin',
new ExistingPlugin(),
],
}
];
const plugins = optionsArray.map(options => new WorkerPlugin(options));