mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Add MultiHook and _pluginCompat to Tapable (#24527)
* Fix Tapable types * .. * Clean up * Undo instance member change * Add constructor to Hookmap
This commit is contained in:
committed by
Mohamed Hegazy
parent
966fe06044
commit
d5cbb8d3cb
18
types/tapable/index.d.ts
vendored
18
types/tapable/index.d.ts
vendored
@@ -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)
|
||||
@@ -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;
|
||||
@@ -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[])
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {Tapable} from "tapable";
|
||||
import {Tapable, MultiHook, SyncHook} from "tapable";
|
||||
|
||||
class DllPlugin {
|
||||
apply(compiler: Compiler) {
|
||||
@@ -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'])]);
|
||||
|
||||
Reference in New Issue
Block a user