You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: type the call and loop interceptor arguments as the hook's own - #288
An interceptor's call and loop are called with the hook's arguments: HookCodeFactory emits _interceptors[i].call(<args>). But they were typed (...args: any[]) => void, so any code that implements them got any. Both are now (...args: AsArray<T>) => void, the same arguments a tap gets.
consthook=newSyncHook<[string,number]>(["name","count"]);hook.intercept({call: (name,count)=>{}// before: any, any — after: string, number});
In webpack, this removes the untyped call interceptor in Compilation. It also surfaces one real mismatch: a typeof hook was handed a node typed only as Node, and webpack fixes that on its own side (webpack/webpack#23309).
HookMap's key stays any. A key type parameter defaulting to any would add any to every HookMap<H> type, and a string or unknown default would break existing factories and interceptors that annotate their key.
What kind of change does this PR introduce?
fix (types)
Did you add tests for your changes?
No. Only tapable.d.ts changes, and the repository has no type tests: npm run lint:types checks lib/** only, so it doesn't cover this file. I verified the declarations two other ways:
A consumer file type-checked against them. On a SyncHook<[string, number]>, call: (name, count) => now gets string and number, and loop: (...args) gets [string, number]. A call whose parameter has the wrong type is rejected. AsyncSeriesHook, SyncLoopHook and (...args) => interceptors still type-check. With the current declarations, the same file gets any and accepts the wrong type.
No for runtime. For types, an interceptor call/loop that declares parameter types which don't match the hook's arguments now fails to type-check. Those parameters were already wrong at runtime. Interceptors written as (...args) => or with matching types are unaffected.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code (investigation, implementation, verification against webpack and this description), directed and reviewed by me.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 625be97d-9a35-4476-91a8-46b5b768fd3f
Commits
Reviewing files that changed from the base of the PR and between a563401 and 3ba2045.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
Walkthrough
The HookInterceptor interface now types the call and loop callback arguments as AsArray<T> instead of any[]. A patch changeset documents the update.
Merge Risk: Minimal · previous review a5634
This is a type-only change to the interceptor call and loop callbacks, with no runtime effect. Only TypeScript users who define context-enabled interceptors outside an object literal could see a new type error, a narrow case with a simple workaround. No merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title says the call and loop interceptor arguments are now typed as the hook's own arguments. The raw summary and objectives confirm that tapable.d.ts changes HookInterceptor call and loop from (.…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title says the call and loop interceptor arguments are now typed as the hook's own arguments. The raw summary and objectives confirm that tapable.d.ts changes HookInterceptor call and loop from (...args: any[]) to (...args: AsArray<T>), and that a patch changeset is added. The title names the main change and fits the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Add type-level tests for the published call and loop declarations.
lint:types runs tsc --noEmit over lib/**/* only, and tapable.d.ts is not included. This PR changes the argument types of call and loop in tapable.d.ts, and no check in the repository exercises those types. A later change that breaks argument inference or accepts an invalid callback signature would pass npm run lint and npm test.
Add a small consumer type test that covers both call and loop. It should check the inferred argument types and reject a mismatched callback signature. The repository has no type-test tooling yet, so this also needs a new tsconfig target and a check script.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 0d337237-d575-4e17-9884-a52afabc046b
Commits
Reviewing files that changed from the base of the PR and between e355aeb and a563401.
Files selected for processing: 2
.changeset/typed-interceptor-arguments.md
tapable.d.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
The benchmark failure isn't from this PR. It fails the same way on main since #286: CodSpeedHQ/action v4.19.1 exits with Unsupported system on the current ubuntu-latest image before any benchmark runs. #289 bumps the action to v5.6.3.
Re-run the base with the same settings to get a valid performance comparison.
Comparing fix/typed-interceptor-arguments (3ba2045) with main (10f5a28)1
Footnotes
No successful run was found on main (9ada8a4) during the generation of this report, so 10f5a28 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An interceptor's
callandloopare called with the hook's arguments:HookCodeFactoryemits_interceptors[i].call(<args>). But they were typed(...args: any[]) => void, so any code that implements them gotany. Both are now(...args: AsArray<T>) => void, the same arguments a tap gets.In webpack, this removes the untyped
callinterceptor inCompilation. It also surfaces one real mismatch: atypeofhook was handed a node typed only asNode, and webpack fixes that on its own side (webpack/webpack#23309).HookMap's key staysany. A key type parameter defaulting toanywould addanyto everyHookMap<H>type, and astringorunknowndefault would break existing factories and interceptors that annotate their key.What kind of change does this PR introduce?
fix (types)
Did you add tests for your changes?
No. Only
tapable.d.tschanges, and the repository has no type tests:npm run lint:typescheckslib/**only, so it doesn't cover this file. I verified the declarations two other ways:SyncHook<[string, number]>,call: (name, count) =>now getsstringandnumber, andloop: (...args)gets[string, number]. Acallwhose parameter has the wrong type is rejected.AsyncSeriesHook,SyncLoopHookand(...args) =>interceptors still type-check. With the current declarations, the same file getsanyand accepts the wrong type.typeofhook node is typed (refactor: type rule effect values, the typeof hook's node and the statement-type hook maps webpack#23309).npm run lintandnpm testpass.Does this PR introduce a breaking change?
No for runtime. For types, an interceptor
call/loopthat declares parameter types which don't match the hook's arguments now fails to type-check. Those parameters were already wrong at runtime. Interceptors written as(...args) =>or with matching types are unaffected.If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code (investigation, implementation, verification against webpack and this description), directed and reviewed by me.
🤖 Generated with Claude Code
https://claude.ai/code/session_01HArJAXZagrHVVNLZZk9soh