Skip to content
Merged
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
2 changes: 1 addition & 1 deletion packages/compose/src/higher-order/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
const basePipe =
( reverse: boolean = false ) =>
( ...funcs: Function[] ) =>
( ...funcs: ( Function | Function[] )[] ) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation below uses funcs.flat(), which means that it always expects an array. 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...funcs always creates an array, but Function[] means every argument must itself be a function.

Existing tests support all these forms:

pipe( a, b, c );
pipe( [ a, b, c ] );
pipe( [ a, b ], c, [ d ], e );

That is why we need ( Function | Function[] )[]. The .flat() call normalizes those mixed arguments. Without the change, the downstream validator reports four type errors.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I don't know why I didn't notice the ... rest operator 🤦

All good.

@ciampo ciampo Aug 31, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many PRs in our inboxes 👀 Pace is hectic

( ...args: unknown[] ) => {
const functions = funcs.flat();
if ( reverse ) {
Expand Down
Loading