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
5 changes: 5 additions & 0 deletions .changeset/typed-hook-map-interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tapable": patch
---

Declare `TypedHookMap` as an interface, as no such class is exported.
9 changes: 5 additions & 4 deletions tapable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ export class HookMap<H> {
intercept(interceptor: HookMapInterceptor<H>): void;
}

type AnyHook = Hook<any, any>;

export class TypedHookMap<M extends Record<any, AnyHook>> {
constructor(factory: HookFactory<M[keyof M], keyof M>, name?: string);
/**
* A `HookMap` whose keys are typed: each key `K` of `M` maps to the hook `M[K]`.
* It is a type only, for annotating a `HookMap`; create one with `new HookMap()`.
*/
export interface TypedHookMap<M extends object> {
name: string | undefined;
get<K extends keyof M>(key: K): M[K] | undefined;
for<K extends keyof M>(key: K): M[K];
Expand Down
Loading