Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions types/tapable/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export declare abstract class Tapable {
[propName: string]: Tapable.Handler[]
}

/** @deprecated Private internals. Do not use directly */
_pluginCompat: Hook;

/**
* @deprecated Tapable.plugin is deprecated. Use new API on `.hooks` instead
* Register plugin(s)
Expand Down Expand Up @@ -275,7 +278,9 @@ export class HookInterceptor {
context: boolean;
}

/** A HookMap is a helper class for a Map with Hooks */
export class HookMap<T1 = any, T2 = any, T3 = any> {
constructor(fn: () => Hook);
get: (key: any) => Hook<T1, T2, T3> | undefined;
for: (key: any) => Hook<T1, T2, T3>;
tap: (key: any, name: string | Tap, fn: (arg1: T1, arg2: T2, arg3: T3, ...args: any[]) => any) => void;
Expand All @@ -287,3 +292,16 @@ export class HookMap<T1 = any, T2 = any, T3 = any> {
export class HookMapInterceptor<T1 = any, T2 = any, T3 = any> {
factory: (key: any, hook: Hook<T1, T2, T3>) => Hook<T1, T2, T3>;
}

/**
* A helper Hook-like class to redirect taps to multiple other hooks
*
* ```
* const { MultiHook } = require("tapable");
*
* this.hooks.allHooks = new MultiHook([this.hooks.hookA, this.hooks.hookB]);
* ```
*/
export class MultiHook {
constructor(hooks: Hook[])
}
4 changes: 3 additions & 1 deletion types/tapable/tapable-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Tapable} from "tapable";
import {Tapable, MultiHook, SyncHook} from "tapable";

class DllPlugin {
apply(compiler: Compiler) {
Expand Down Expand Up @@ -43,3 +43,5 @@ compiler.applyPluginsAsyncWaterfall('doSomething', 'a', callback);
compiler.applyPluginsParallel('doSomething', 'a', 'b');
compiler.applyPluginsParallelBailResult('doSomething', 'a', 'b');
compiler.applyPluginsParallelBailResult1('doSomething', 'a', callback);

const multi = new MultiHook([new SyncHook(['hi'])]);