Skip to content

[@types/underscore] Collection and Array Tests - SortBy, IndexBy, CountBy, and Invoke#46352

Merged
typescript-bot merged 5 commits intoDefinitelyTyped:masterfrom
reubenrybnik:underscore-tests-sortBy-indexBy-countBy
Jul 28, 2020
Merged

[@types/underscore] Collection and Array Tests - SortBy, IndexBy, CountBy, and Invoke#46352
typescript-bot merged 5 commits intoDefinitelyTyped:masterfrom
reubenrybnik:underscore-tests-sortBy-indexBy-countBy

Conversation

@reubenrybnik
Copy link
Copy Markdown
Contributor

@reubenrybnik reubenrybnik commented Jul 26, 2020

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).
  • Provide a URL to documentation or source code which provides context for the suggested changes: https://underscorejs.org/
  • Include tests for your changes

This PR continues the planned set that will together add up to #45201 and includes the following changes:

  • Adds tests for sortBy, indexBy, countBy, and invoke.
  • Updates sortBy, indexBy, countBy, and invoke to use Collection and Iteratee to partially fix Underscore collections functions should take objects #20623.
  • Updates invoke return types from any and T to any[].
  • Updates the return type of _Chain.sortBy, _Chain.indexBy, _Chain.countBy, and _Chain.invoke to use the correct wrapped value type V to partially fix @types/underscore error TS2322 for _.chain after upgrade to v1.9 #36308.
  • Updates the collection type result for _Chain.countBy to be number instead of T.
  • Updates overloads of groupBy to be more consistent with these overloads by making tweaks to summary comments, making iteratee optional, and adding tests for all iteratee types.
  • Updates test group comments for max and min to say "iteratee" instead of "iterator" because I messed that up in my last PR.

This is the last PR in the Collections family.

@typescript-bot typescript-bot added Where is GH Actions? GH Actions didn't give a response to this PR Popular package This PR affects a popular package (as counted by NPM download counts). Author is Owner The author of this PR is a listed owner of the package. labels Jul 26, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Jul 26, 2020

@reubenrybnik Thank you for submitting this PR!

This is a live comment which I will keep updated.

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • ✅ Most recent commit is approved by type definition owners or DT maintainers

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": 46352,
  "author": "reubenrybnik",
  "owners": [
    "borisyankov",
    "jbaldwin",
    "ccurrens",
    "confususs",
    "jgonggrijp",
    "ffflorian",
    "regevbr",
    "peterblazejewicz",
    "reubenrybnik"
  ],
  "dangerLevel": "ScopedAndTested",
  "headCommitAbbrOid": "50f6f6c",
  "headCommitOid": "50f6f6c58c7c80ed2ddc274da254143e774b1077",
  "mergeIsRequested": true,
  "stalenessInDays": 0,
  "lastPushDate": "2020-07-27T23:28:05.000Z",
  "lastCommentDate": "2020-07-28T21:14:14.000Z",
  "maintainerBlessed": false,
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46352/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-28T19:31:15.000Z",
  "reviewersWithStaleReviews": [],
  "approvalFlags": 2,
  "isChangesRequested": false
}

@typescript-bot
Copy link
Copy Markdown
Contributor

🔔 @borisyankov @jbaldwin @ccurrens @confususs @jgonggrijp @ffflorian @regevbr @peterblazejewicz — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot removed the Where is GH Actions? GH Actions didn't give a response to this PR label Jul 26, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

👋 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 📊
master #46352 diff
Batch compilation
Memory usage (MiB) 58.9 64.0 +8.6%
Type count 12020 12708 +6%
Assignability cache size 1461 1468 0%
Language service
Samples taken 6815 7272 +7%
Identifiers in tests 6815 7272 +7%
getCompletionsAtPosition
    Mean duration (ms) 193.4 196.1 +1.4%
    Mean CV 8.3% 7.6%
    Worst duration (ms) 356.5 405.8 +13.8%
    Worst identifier _ stringMemo
getQuickInfoAtPosition
    Mean duration (ms) 188.1 191.6 +1.9%
    Mean CV 8.1% 7.9% -3.2%
    Worst duration (ms) 376.2 420.1 +11.7%
    Worst identifier extractChainTypes extractUnderscoreTypes

It looks like nothing changed too much. I won’t post performance data again unless it gets worse.

@typescript-bot typescript-bot added the Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. label Jul 26, 2020
@reubenrybnik reubenrybnik changed the title [@types/underscore] Collection and Array Tests - SortBy, IndexBy, and CountBy [@types/underscore] Collection and Array Tests - SortBy, IndexBy, CountBy, and Invoke Jul 27, 2020
@reubenrybnik
Copy link
Copy Markdown
Contributor Author

As mentioned in #46306, there are some more exciting revisions to invoke that I now plan to make in a separate PR after #45201 is closed where I'll bump the TS version up as high as I can.

Copy link
Copy Markdown
Contributor

@jgonggrijp jgonggrijp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another breeze!

@typescript-bot typescript-bot added Owner Approved A listed owner of this package signed off on the pull request. Self Merge This PR can now be self-merged by the PR author or an owner labels Jul 28, 2020
@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Thanks @jgonggrijp, this is the last PR for Collections! Just two more PRs for Arrays, one for your requested changes to Objects, and some cleanup 😁

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot merged commit a8dcb61 into DefinitelyTyped:master Jul 28, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

I just published @types/underscore@1.10.16 to npm.

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Darn, forgot to re-run the latest set of changes against my company's solution, with the switch to requiring a result of EnumerableKey I get one new error where an iterator in groupBy results in string | undefined. I think it's good for that to be an error though since we should probably filter out the undefined cases (or come up with a better default key) instead of ending up with a weird "undefined" key (or at least explicitly choose to end up with that).

astorije pushed a commit to astorije/DefinitelyTyped that referenced this pull request Jul 30, 2020
…rray Tests - SortBy, IndexBy, CountBy, and Invoke by @reubenrybnik

* Updating type definitions for sortBy, indexBy, and countBy and adding tests.

* Switching "iterator" to "iteratee" for a few test groups.

* Making a few adjustments to groupBy to better match similar functions.

* Updating type definitions for invoke and adding tests.

* Constraining allowed iteratee results for groupBy, indexBy, and countBy to EnumerableKey.
danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
…rray Tests - SortBy, IndexBy, CountBy, and Invoke by @reubenrybnik

* Updating type definitions for sortBy, indexBy, and countBy and adding tests.

* Switching "iterator" to "iteratee" for a few test groups.

* Making a few adjustments to groupBy to better match similar functions.

* Updating type definitions for invoke and adding tests.

* Constraining allowed iteratee results for groupBy, indexBy, and countBy to EnumerableKey.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author is Owner The author of this PR is a listed owner of the package. Owner Approved A listed owner of this package signed off on the pull request. Perf: Same typescript-bot determined that this PR will not significantly impact compilation performance. Popular package This PR affects a popular package (as counted by NPM download counts). Self Merge This PR can now be self-merged by the PR author or an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@types/underscore error TS2322 for _.chain after upgrade to v1.9 Underscore collections functions should take objects

3 participants