fix(pipe): proper TypeScript typing with function overloads#235
Merged
fix(pipe): proper TypeScript typing with function overloads#235
Conversation
- Add function overloads for pipe (up to 7 functions) for proper type inference - Add function overloads for flow where first function can accept multiple arguments - Replace reduce with for loop for better performance - Update examples in JSDoc Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Add comprehensive tests for pipe and flow functions to improve coverage. Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Test scheduler.yield, setImmediate, and MessageChannel paths. Verify immediate is same reference as yieldControl. Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Add pipeAsync for async composition with Promise unwrapping at each step - Add flowAsync for creating reusable async composed functions - Add tap for side effects without altering the value - Add tapAsync for async side effects - All new functions have proper TypeScript overloads for type inference Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Replace Function type with AnyFn for better type safety - Add thenable check in pipeAsync/flowAsync to avoid unnecessary microtasks - Add tapSafe for error-safe side effects - Add comprehensive tests for tapSafe Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
- Add function check to isThenable for better compatibility with thenable objects - Check initial value in pipeAsync to avoid unnecessary microtasks Note: Kept AnyFn with unknown[] instead of any to satisfy strict lint rules. Overloads provide public-facing type safety regardless. Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
Re-add Promise<unknown> casts that were accidentally removed during rebase. Keeping unknown types for lint compliance. Co-Authored-By: martyy-code <nesalia.inc@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
pipe(up to 7 functions) for proper type inferenceflowwhere first function can accept multiple argumentsreducewithforloop for better performancepipeAsync— async composition with Promise unwrapping at each stepflowAsync— create reusable async composed functionstap— execute side effects without altering the value (for logging/debugging)tapAsync— async version of tap for analytics/trackingBenefits
flow((a, b) => a + b, n => n.toString())(5, 10)workspipeAsync/flowAsyncfor async compositiontap/tapAsyncfor logging/monitoringforloop is faster thanreduceTest plan
retry.ts(87.5% branches) has coverage below 95% threshold. This is not caused by this PR.🤖 Generated with Claude Code