-
-
Notifications
You must be signed in to change notification settings - Fork 4k
types(collection): reduce* method signatures #10405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kodiakhq
merged 4 commits into
discordjs:main
from
Renegade334:collection-reduce-signatures
Jul 28, 2024
Merged
types(collection): reduce* method signatures #10405
kodiakhq
merged 4 commits into
discordjs:main
from
Renegade334:collection-reduce-signatures
Jul 28, 2024
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10405 +/- ##
==========================================
+ Coverage 50.73% 50.75% +0.01%
==========================================
Files 228 228
Lines 20646 20652 +6
Branches 1253 1261 +8
==========================================
+ Hits 10475 10481 +6
Misses 10127 10127
Partials 44 44
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
kyranet
requested changes
Jul 22, 2024
34bee55 to
8532df9
Compare
kyranet
approved these changes
Jul 25, 2024
vladfrangu
approved these changes
Jul 28, 2024
didinele
approved these changes
Jul 28, 2024
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.
Please describe the changes this PR makes and why it should be merged:
Small changes relating to the typed method definitions for
reduce()andreduceRight():reduceRight().initialValuewas not provided, this method would previously accept a callback with any arbitrary type forpreviousValue, or infer the type asunknownwithout explicit type annotation:previousValuetype is always the collection value type, and will raise an error otherwise.Array.prototype.reduce.initialValueis provided with a type that is assignable to, but not equal to, the collection value type:InitialValuewould be inferred as1 | 2 | 3, leading to compilation errors.initialValueis assignable to the collection value type, the method signature will preferentially use the collection value type for the callback, rather than narrowing to the type ofinitialValue. This matches the behaviour ofArray.prototype.reducein TypeScript.Also adds one missing
reduceRight()test (reduce empty collection with initial value).