diff --git a/types/worker-plugin/index.d.ts b/types/worker-plugin/index.d.ts new file mode 100644 index 0000000000..fc8b439d71 --- /dev/null +++ b/types/worker-plugin/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for worker-plugin 3.2 +// Project: https://github.com/GoogleChromeLabs/worker-plugin +// Definitions by: Artur Androsovych +// 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; + } +} diff --git a/types/worker-plugin/tsconfig.json b/types/worker-plugin/tsconfig.json new file mode 100644 index 0000000000..84fd19fa53 --- /dev/null +++ b/types/worker-plugin/tsconfig.json @@ -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" + ] +} diff --git a/types/worker-plugin/tslint.json b/types/worker-plugin/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/worker-plugin/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/worker-plugin/worker-plugin-tests.ts b/types/worker-plugin/worker-plugin-tests.ts new file mode 100644 index 0000000000..3389c27791 --- /dev/null +++ b/types/worker-plugin/worker-plugin-tests.ts @@ -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));