Array predicates should not have to return boolean#27509
Closed
NikolajDL wants to merge 5 commits intomicrosoft:masterfrom
Closed
Array predicates should not have to return boolean#27509NikolajDL wants to merge 5 commits intomicrosoft:masterfrom
NikolajDL wants to merge 5 commits intomicrosoft:masterfrom
Conversation
- Adds tests to above change
- Adds tests to above change
- Adds tests to above change
- Adds tests to above change
Member
|
Test bench: function filter1<T>(arr: T[], pred: (arg: T) => any) { }
function filter2<T>(arr: T[], pred: (arg: T) => unknown) { }
function filter3<T>(arr: T[], pred: (arg: T) => boolean) { }
function filter4<T>(arr: T[], pred: (arg: T) => {}) { }
function filter5<T>(arr: T[], pred: (arg: T) => {} | null | undefined) { }
const arr = [0];
filter1(arr, i => { });
filter1(arr, i => "");
filter1(arr, i => { return; });
filter1(arr, i => { return null; });
filter1(arr, i => { return undefined; });
filter2(arr, i => { });
filter2(arr, i => "");
filter2(arr, i => { return; });
filter2(arr, i => { return null; });
filter2(arr, i => { return undefined; });
filter3(arr, i => { });
filter3(arr, i => "");
filter3(arr, i => { return; });
filter3(arr, i => { return null; });
filter3(arr, i => { return undefined; });
filter4(arr, i => { });
filter4(arr, i => "");
filter4(arr, i => { return; });
filter4(arr, i => { return null; });
filter4(arr, i => { return undefined; });
filter5(arr, i => { });
filter5(arr, i => "");
filter5(arr, i => { return; });
filter5(arr, i => { return null; });
filter5(arr, i => { return undefined; });I think |
Author
|
I agree, but it would still be slightly more restrictive than the filter function in plain JavaScript. Following the discussion in #5850 it sounds like Should I change the |
…r array functions find, findIndex, some and every - Extends test cases for previous commits in this branch, to better reflect the expected behavior
Member
|
I'm going to take this to the design meeting |
Member
|
This one's a bit out of date and we'd prefer a change to |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Changes predicate return type from
booleantoanyfor array operationsfind,findIndex,someandevery, such that the behavior matches that of thefilteroperation.Fixes #27496