[@types/underscore] Collection and Array Tests - Find and Reject#45994
Conversation
|
@reubenrybnik Thank you for submitting this PR! This is a live comment which I will keep updated. Code ReviewsBecause you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it. Status
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes. Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 45994,
"author": "reubenrybnik",
"owners": [
"borisyankov",
"jbaldwin",
"ccurrens",
"confususs",
"jgonggrijp",
"ffflorian",
"regevbr",
"peterblazejewicz",
"reubenrybnik"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "71bbdd7",
"headCommitOid": "71bbdd7fc4e25219a16c9985198471882e738c8c",
"mergeIsRequested": true,
"stalenessInDays": 0,
"lastPushDate": "2020-07-10T20:48:23.000Z",
"lastCommentDate": "2020-07-11T00:00:29.000Z",
"maintainerBlessed": false,
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45994/files",
"hasMergeConflict": false,
"authorIsOwner": true,
"isFirstContribution": false,
"popularityLevel": "Popular",
"anyPackageIsNew": false,
"packages": [
"underscore"
],
"files": [
{
"path": "types/underscore/index.d.ts",
"kind": "definition",
"package": "underscore"
},
{
"path": "types/underscore/underscore-tests.ts",
"kind": "test",
"package": "underscore"
}
],
"hasDismissedReview": false,
"ciResult": "pass",
"lastReviewDate": "2020-07-10T21:27:28.000Z",
"reviewersWithStaleReviews": [],
"approvalFlags": 2,
"isChangesRequested": false
} |
|
🔔 @borisyankov @jbaldwin @ccurrens @confususs @jgonggrijp @ffflorian @regevbr @peterblazejewicz - please review this PR in the next few days. Be sure to explicitly select |
…roofing because even though this works as-is it seems like any should pass an extends List or extends Dictionary check.
jgonggrijp
left a comment
There was a problem hiding this comment.
This is starting to feel smooth. Nice work. "Request changes" in this case is mostly just a request for additional tests, the rest is pretty minor.
|
@reubenrybnik One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. If you disagree with the reviewer's comments, you can "dismiss" the review using GitHub's review UI. Thank you! |
|
👋 Hi there! I’ve run some quick measurements against master and your PR. These metrics should help the humans reviewing this PR gauge whether it might negatively affect compile times or editor responsiveness for users who install these typings. Let’s review the numbers, shall we? Comparison details 📊
It looks like nothing changed too much. I won’t post performance data again unless it gets worse. |
…reject and alternating between lists and dictionaries for non-function iteratees since covering both cases for those iteratees is not as interesting.
|
@jgonggrijp Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review? |
…erred and adding any tests for find, filter, and reject.
jgonggrijp
left a comment
There was a problem hiding this comment.
I'm content, just a few more nitpicks. Especially two tests where I suspect you forgot to remove the stringRecordProperty arguments.
Co-authored-by: Julian Gonggrijp <dev@juliangonggrijp.com>
|
From my company's solution, I get two new errors. For the first one, we're using |
jgonggrijp
left a comment
There was a problem hiding this comment.
From my company's solution, I get two new errors. For the first one, we're using
findlikeeachbut returning nothing rather than a boolean that would act like a break statement (which it looks like worked in the previous definition by inappropriately falling back to theiterator: (U extends {})overload).
Out of curiosity, is there a particular reason to use find as each?
For the second, we're explicitly specifying a generic when we don't need to, which breaks because the generic changed from
TtoV. Both seem like reasonable errors to me.
I agree. Again, good job and thanks for your hard work!
|
Thanks @jgonggrijp! Underscore documentation mentions using |
|
Yes I know that, in fact find is the functional programming counterpart of a |
|
We should ideally be returning a Boolean but the person that wrote it missed doing that, so it's a good error that I'm glad is now happening with these updates and that I look forward to fixing 😄 Happily it's just slightly more inefficient than it could be rather than being wrong in a dangerous way. |
|
Ready to merge |
|
I just published |
…rray Tests - Find and Reject by @reubenrybnik * Updating type definitions for find and reject and adding tests. * Updating summary comment indentation for a few see comments that I missed previously. * Updating TypeOfCollection<any> to result in any instead of unknown. * Moving the never check up to the top of TypeOfCollection for future-proofing because even though this works as-is it seems like any should pass an extends List or extends Dictionary check. * Adding support and tests for identity iteratees in find, filter, and reject and alternating between lists and dictionaries for non-function iteratees since covering both cases for those iteratees is not as interesting. * Adding any and never tests to OOP and chain. * Summary comment updates suggested by @jgonggrijp. * Adding a boolean iterator that won't cause collection types to be inferred and adding any tests for find, filter, and reject. * Fixing identity iteratee tests that I didn't properly switch to an identity iteratee. * Remove a filter designation from a reject test group. Co-authored-by: Julian Gonggrijp <dev@juliangonggrijp.com> Co-authored-by: Julian Gonggrijp <dev@juliangonggrijp.com>
…rray Tests - Find and Reject by @reubenrybnik * Updating type definitions for find and reject and adding tests. * Updating summary comment indentation for a few see comments that I missed previously. * Updating TypeOfCollection<any> to result in any instead of unknown. * Moving the never check up to the top of TypeOfCollection for future-proofing because even though this works as-is it seems like any should pass an extends List or extends Dictionary check. * Adding support and tests for identity iteratees in find, filter, and reject and alternating between lists and dictionaries for non-function iteratees since covering both cases for those iteratees is not as interesting. * Adding any and never tests to OOP and chain. * Summary comment updates suggested by @jgonggrijp. * Adding a boolean iterator that won't cause collection types to be inferred and adding any tests for find, filter, and reject. * Fixing identity iteratee tests that I didn't properly switch to an identity iteratee. * Remove a filter designation from a reject test group. Co-authored-by: Julian Gonggrijp <dev@juliangonggrijp.com> Co-authored-by: Julian Gonggrijp <dev@juliangonggrijp.com>

npm test.)npm run lint package-name(ortscif notslint.jsonis present).This PR continues the planned set that will together add up to #45201 and includes the following changes:
findandreject.findandrejectto useIteratee.Tgeneric inUnderscore.findand_Chain.find._Chain.rejectto use the correct wrapped value typeVto partially fix @types/underscore error TS2322 for_.chainafter upgrade to v1.9 #36308.Underscoreand_Chainversions ofrejectto work with both Lists and Dictionaries to partially fix Underscore collections functions should take objects #20623.detectoverloads with a reference tofindoverloads.TypeOfCollectionto extractanyinstead ofunknownas the collection item type foranyfor better backwards compatibility.filterto support an identity iteratee.@returnsforfilterto better match the one forreject.