@@ -34,23 +34,7 @@ const { fileUrlToPath } = require("../util/identifier");
3434 * @property {AbsolutePath= } outputPath Path to the output file e.g. `path.resolve(__dirname, 'profiling/events.json')`. Defaults to `events.json`.
3535 */
3636
37- /**
38- * Defines the hook type used by this module.
39- * @template T, R
40- * @typedef {import("tapable").Hook<T, R> } Hook
41- */
42-
43- /**
44- * Defines the fake hook type used by this module.
45- * @template T
46- * @typedef {import("../util/deprecation").FakeHook<T> } FakeHook
47- */
48-
49- /**
50- * Defines the hook map type used by this module.
51- * @template T
52- * @typedef {import("tapable").HookMap<T> } HookMap
53- */
37+ /** @import { FakeHookMarker } from "../util/deprecation" */
5438
5539/**
5640 * Defines the hook interceptor type used by this module.
@@ -408,27 +392,43 @@ class ProfilingPlugin {
408392 }
409393}
410394
411- /** @typedef {Record<string, Hook<EXPECTED_ANY, EXPECTED_ANY> | FakeHook<EXPECTED_ANY> | HookMap<EXPECTED_ANY>> } Hooks */
395+ /**
396+ * The part of a tapable `HookInterceptor` this plugin sets: it rewraps each tap.
397+ * @typedef {{ register?(tap: FullTap): FullTap } } TapInterceptor
398+ */
399+
400+ /**
401+ * What intercepting a tapable `Hook` needs of it. Methods, so every hook fits
402+ * whatever its arguments, result and additional tap options.
403+ * @typedef {{ intercept(interceptor: TapInterceptor): void, _fakeHook?: undefined } } HookWithInterceptor
404+ */
405+
406+ /**
407+ * What intercepting a tapable `HookMap` needs of it, whatever hook it holds.
408+ * @typedef {{ for(key: string): HookWithInterceptor, intercept(interceptor: { factory?(key: string, hook: HookWithInterceptor): HookWithInterceptor }): void, _fakeHook?: undefined } } HookMapWithInterceptor
409+ */
410+
411+ /** @typedef {Record<string, HookWithInterceptor | HookMapWithInterceptor | FakeHookMarker> } Hooks */
412412
413413/**
414414 * Intercepts the taps of a hook or every cached and future hook in a hook map.
415- * @param {Hooks[string] } hook the hook or hook map
416- * @param {HookInterceptor<EXPECTED_ANY, EXPECTED_ANY> } interceptor what intercepts each tap
415+ * @param {HookWithInterceptor | HookMapWithInterceptor } hook the hook or hook map
416+ * @param {TapInterceptor } interceptor what intercepts each tap
417417 * @returns {void }
418418 */
419419const interceptTaps = ( hook , interceptor ) => {
420420 if ( "for" in hook ) {
421421 const { _map } =
422- /** @type {HookMap<Hook<EXPECTED_ANY, EXPECTED_ANY>> & { _map: Map<string, Hook<EXPECTED_ANY, EXPECTED_ANY> > } } */
422+ /** @type {HookMapWithInterceptor & { _map: Map<string, HookWithInterceptor > } } */
423423 ( hook ) ;
424424 for ( const cached of _map . values ( ) ) {
425425 cached . intercept ( interceptor ) ;
426426 }
427427 hook . intercept ( {
428428 /**
429429 * @param {string } key the key the hook is created for
430- * @param {Hook<EXPECTED_ANY, EXPECTED_ANY> } created the hook created
431- * @returns {Hook<EXPECTED_ANY, EXPECTED_ANY> } the same hook, intercepted
430+ * @param {HookWithInterceptor } created the hook created
431+ * @returns {HookWithInterceptor } the same hook, intercepted
432432 */
433433 factory : ( key , created ) => {
434434 created . intercept ( interceptor ) ;
0 commit comments