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
[@types/underscore] Collection and Array Tests - Each, ToArray, and Partition #46120
[@types/underscore] Collection and Array Tests - Each, ToArray, and Partition #46120
Conversation
…h by redefining CollectionIterator to only use conditional types to determine the potential key type for the iterator.
…and updating the base each tests to be a more interesting and abbreviated.
@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": 46120,
"author": "reubenrybnik",
"owners": [
"borisyankov",
"jbaldwin",
"ccurrens",
"confususs",
"jgonggrijp",
"ffflorian",
"regevbr",
"peterblazejewicz",
"reubenrybnik"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "5ef8fe2",
"headCommitOid": "5ef8fe2907257beac41e27c3dc2399a087eddb67",
"mergeIsRequested": true,
"stalenessInDays": 0,
"lastPushDate": "2020-07-17T14:12:06.000Z",
"lastCommentDate": "2020-07-19T20:17:06.000Z",
"maintainerBlessed": false,
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46120/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-19T20:19:03.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 |
👋 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly agree with the changes, just a few details.
@types/underscore
has improved a lot since you started this project and it is a joy to see it still moving forward. Keep it up. 👍
@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! |
…iteratee tests for find, filter, and reject more realistic by using potentially falsy types.
…ing it got updated at some point and I forgot to remove it at that time.
…ways a function.
…es instead of types and updating MemoCollectionIterator to use the same pattern as CollectionIterator.
… usages elsewhere in these definitions.
…of the extends checks in MemoCollectionIterator seems to have gotten rid of the result narrowing issue that was previously preventing that from working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're done here. I look forward to the next one!
Thanks @jgonggrijp! I appreciate your attentiveness to these reviews and the ideas you've provided throughout this process that have helped to make these changes much better than I'd originally planned. From a PR count perspective, this puts us at about the halfway point in my current planned set (which has changed a little from the set I originally mentioned in #45304). I'll wait until at least 7PM UTC |
Glad to hear that! That's the main reason for doing it so I'm glad it works.
Only halfway, haha.
I made a small reply. Unless you want to make further decisions depend on whatever discussion might come after that, the rest of the "grace period" is not necessary as far as I'm concerned.
It's always worth striving to better organize your thoughts and to double-check your work, but please don't be so hard on yourself. I'm quite sure I've made a few mistakes as well, especially when it comes to realism about what the TS compiler will do. Humans in general are (intensely) fallible, that's why we tend to get so much better results when we team up. By the way, I've been tweeting about our reviews and the tweets seem to attract some interest. If you happen to be on Twitter, it may be nice to associate. (I tried finding you but couldn't be sure.) |
We are probably more than halfway along with regards to effort though 🎉
Sounds good, I'll hit the go button now then 😄
Sorry to disappoint here, but while I made a Twitter account once upon a time and so can technically be said to exist there I've never actually tweeted with it (and off the top of my head I don't even remember my handle). Happy to hear, though, that others might be finding this work to be valuable or interesting 😁 |
Ready to merge |
Hmm, sorry @jgonggrijp, I didn't add any commits but somehow something one of us did surprisingly seems to have caused your approval to not apply anymore as indicated by this tag removal. If you wouldn't mind clicking approve one more time on this, I'd appreciate it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious. Well, here we go again!
I just published |
Hmm, another interesting interaction here, not the biggest fan of how my previous "Ready to merge" caused this to be merged at the moment of your re-approval since I feel like a merge should only be triggered when the author is the one taking an action 😕 |
That was probably meant to be smart. But I agree it's unexpected. |
…rray Tests - Each, ToArray, and Partition by @reubenrybnik * Updating type definitions for each, partition, and toArray and adding tests. * Adding a multi-call chain test. * Fixing some issues around type unions and implicit any errors for each by redefining CollectionIterator to only use conditional types to determine the potential key type for the iterator. * Adding tests around issues fixed by the change to CollectionIterator and updating the base each tests to be a more interesting and abbreviated. * Adding identity iteratee tests for partition and making the identity iteratee tests for find, filter, and reject more realistic by using potentially falsy types. * Removing IterateePropertyShorthand because the last thing that was using it got updated at some point and I forgot to remove it at that time. * Update summary comments to reflect that the iteratee for `each` is always a function. * Moving EnumerableKey and CollectionKey up above the iterators. * Updating CollectionIterator and MemoCollectionIterator to be interfaces instead of types and updating MemoCollectionIterator to use the same pattern as CollectionIterator. * Updating Array<EnumerableKey> to EnumerableKey[] to match other array usages elsewhere in these definitions. * Adding tests for the more complicated Iteratee and IterateeResult types. * Dropping extra overloads of reduce and reduceRight since getting rid of the extends checks in MemoCollectionIterator seems to have gotten rid of the result narrowing issue that was previously preventing that from working. * Dropping MemoIterator and MemoObjectIterator since they're no longer referenced. * While I'm cleaning up reduce and reduceRight anyway, also updating the Underscore and _Chain versions of them to use T instead of TypeOfCollection<V> more often. * Revert "Dropping MemoIterator and MemoObjectIterator since they're no longer referenced." This reverts commit 53d6759. * Updating non-collection iterator types to be aliases of collection iterator types. * Putting better constraints on iterators and temporarily reverting back to not using T in a few places to compensate. * Adding missing $ExpectTypes in function Iteratee tests. * Adding null to Iteratee and IterateeResult and moving undefined to the end of those types. * Adding null iteratee tests.
Since DefinitelyTyped#190 we ignore "ready to merge" comments predating the most recent review. That change explicitly discounts the most recent comment date, so additional comments don't trample the "ready to merge" request, however additional approvals still do: DefinitelyTyped/DefinitelyTyped#48236 We can't drop the `lastReviewDate` from the `sinceDates` entirely without reopening DefinitelyTyped#164, demonstrated in DefinitelyTyped/DefinitelyTyped#46120, so the next simplest thing is to replace it with the earliest (non-stale) approval date. This works for DefinitelyTyped/DefinitelyTyped#46120 (continues to ignore requests preceding approval) and DefinitelyTyped/DefinitelyTyped#48236 (additional approvals don't trample requests, like additional comments don't).
Since #190 we ignore "ready to merge" comments predating the most recent review. That change explicitly discounts the most recent comment date, so additional comments don't trample the "ready to merge" request, however additional approvals still do: DefinitelyTyped/DefinitelyTyped#48236 We can't drop the `lastReviewDate` from the `sinceDates` entirely without reopening #164, demonstrated in DefinitelyTyped/DefinitelyTyped#46120, so the next simplest thing is to replace it with the earliest (non-stale) approval date. This works for DefinitelyTyped/DefinitelyTyped#46120 (continues to ignore requests preceding approval) and DefinitelyTyped/DefinitelyTyped#48236 (additional approvals don't trample requests, like additional comments don't).
npm test
.)npm run lint package-name
(ortsc
if notslint.json
is present).This PR continues the planned set that will together add up to #45201 and includes the following changes:
each
,toArray
, andpartition
.each
by updating it to useCollectionIterator
.each
to be the exact original collection type rather than an approximation.partition
to useCollection
andIteratee
to partially fix Underscore collections functions should take objects #20623.partition
to result in a two-item tuple instead of an array.Underscore.partition
and_Chain.partition
to be in the Collections sections of those interfaces._Chain.each
,_Chain.toArray
, and_Chain.partition
to use the correct wrapped value typeV
to partially fix @types/underscore error TS2322 for_.chain
after upgrade to v1.9 #36308.Underscore
and_Chain
versions ofreject
to work with both Lists and Dictionaries to partially fix Underscore collections functions should take objects #20623.forEach
overloads with a reference toeach
overloads.CollectionIterator
andMemoCollectionIterator
around element type inference with collections that are type unions orany
.