Skip to content

[@types/underscore] Collection and Array Tests - Type Extractors#45717

Merged
typescript-bot merged 5 commits intoDefinitelyTyped:masterfrom
reubenrybnik:underscore-tests-chain-type-extractors
Jun 28, 2020
Merged

[@types/underscore] Collection and Array Tests - Type Extractors#45717
typescript-bot merged 5 commits intoDefinitelyTyped:masterfrom
reubenrybnik:underscore-tests-chain-type-extractors

Conversation

@reubenrybnik
Copy link
Copy Markdown
Contributor

  • 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:

  • Per conversations with @jgonggrijp, introduces a combination of type extracting interfaces and functions for UnderscoreStatic and UnderscoreStatic.chain function result evaluation in test code that will hopefully help keep future changes to underlying Underscore types from requiring large swaths of changes to tests.
  • Simplifies the UnderscoreStatic and UnderscoreStatic.chain functions in a way that makes them better at handling types with mixed iterability (e.g. number | number[]) which ideally should provide wrapper results that support calls to iterative functions.
  • Updates TypeOfCollection to check against List and Dictionary separately rather than checking against Collection since inference using the latter type interacts very unpleasantly with JQuery objects for some reason in a way that inference from the List and Dictionary types alone do not replicate.

…rscore and chain functions to a single overload.
…tely instead of using Collection since using the latter behaves oddly with JQuery objects.
@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 Jun 26, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Jun 26, 2020

@reubenrybnik Thank you for submitting this PR!

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": 45717,
  "author": "reubenrybnik",
  "owners": [
    "borisyankov",
    "jbaldwin",
    "ccurrens",
    "confususs",
    "jgonggrijp",
    "ffflorian",
    "regevbr",
    "peterblazejewicz",
    "reubenrybnik"
  ],
  "dangerLevel": "ScopedAndTested",
  "headCommitAbbrOid": "d67689f",
  "headCommitOid": "d67689f4a1eaa3c4c7fe9f6615db6aecb1824e24",
  "mergeIsRequested": true,
  "stalenessInDays": 0,
  "lastCommitDate": "2020-06-27T07:34:26.000Z",
  "lastCommentDate": "2020-06-28T02:07:34.000Z",
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45717/files",
  "hasMergeConflict": false,
  "authorIsOwner": true,
  "isFirstContribution": false,
  "popularityLevel": "Popular",
  "anyPackageIsNew": false,
  "packages": [
    "underscore"
  ],
  "files": [
    {
      "filePath": "types/underscore/index.d.ts",
      "kind": "definition",
      "package": "underscore"
    },
    {
      "filePath": "types/underscore/underscore-tests.ts",
      "kind": "test",
      "package": "underscore"
    }
  ],
  "hasDismissedReview": false,
  "ciResult": "pass",
  "lastReviewDate": "2020-06-28T00:43:48.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 Jun 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?

master #45717 diff
Batch compilation
Memory usage (MiB) 57.2 51.7 -9.5%
Type count 8983 9729 +8%
Assignability cache size 1191 1495 +26%
Language service
Samples taken 2085 2160 +4%
Identifiers in tests 2085 2160 +4%
getCompletionsAtPosition
    Mean duration (ms) 173.6 181.0 +4.3%
    Mean CV 12.0% 11.6%
    Worst duration (ms) 327.5 409.7 +25.1% 🔸
    Worst identifier value _
getQuickInfoAtPosition
    Mean duration (ms) 165.9 173.3 +4.5%
    Mean CV 11.9% 11.5% -3.5%
    Worst duration (ms) 292.4 461.4 +57.8% 🔸
    Worst identifier value extractChainTypes

Looks like there were a couple significant differences—take a look at worst-case duration for getting completions at a position and worst-case duration for getting quick info at a position to make sure everything looks ok.

@typescript-bot typescript-bot added the Perf: Worse typescript-bot determined that this PR has a negative impact on compilation performance. label Jun 26, 2020
@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Sorry performance benchmarking check, but I don't understand what you're unhappy about, and since one of the things you're complaining about is a test helper function I'm not convinced that you're telling me anything useful about what users will experience so I'm not super motivated to do anything about what you're reporting.

@typescript-bot
Copy link
Copy Markdown
Contributor

Updated numbers for you here from 589517c.

Comparison details 📊
master #45717 diff
Batch compilation
Memory usage (MiB) 57.3 51.7 -9.8%
Type count 8983 9729 +8%
Assignability cache size 1191 1495 +26%
Language service
Samples taken 2085 2160 +4%
Identifiers in tests 2085 2160 +4%
getCompletionsAtPosition
    Mean duration (ms) 178.5 179.4 +0.5%
    Mean CV 11.1% 11.2%
    Worst duration (ms) 343.0 388.3 +13.2%
    Worst identifier chain mixedIterabilityValue
getQuickInfoAtPosition
    Mean duration (ms) 171.1 171.7 +0.3%
    Mean CV 10.8% 11.1% +2.8%
    Worst duration (ms) 302.6 383.2 +26.6% 🔸
    Worst identifier detect extractChainTypes

Looks like there were a couple significant differences—take a look at worst-case duration for getting quick info at a position to make sure everything looks ok.

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.

I agree with these changes.

A soft request for adjustment, however: please reduce the length of names in the tests. While I understand that a name like stronglyKeyedSimpleStringObjectDictionary is meant to be self-documenting, the brain strain required to parse such a long name makes me just grab for the search function to look up the definition of the symbol instead, so you may as well have called it banana (not meant as a concrete suggestion). Adding to that, it takes up a lot of space and it makes it harder to get a bird's-eye view of the code as a result. All in all, it hurts the readability of the code instead of improving it.

I suggest concatenating at most three words as a rule of thumb, preferably fewer. Perhaps there are common combinations of words that can be replaced by a single, more expressive word. For example, I would suggest explicit instead of stronglyKeyed and Record instead of SimpleStringObject. It may also not always be necessary to give a complete description of a symbol in its name.

@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 Jun 26, 2020
@typescript-bot typescript-bot removed Self Merge This PR can now be self-merged by the PR author or an owner Owner Approved A listed owner of this package signed off on the pull request. labels Jun 27, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

@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?

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @jgonggrijp! In particular, I definitely went a little crazy unnecessarily calling everything simple 😬.

I admittedly didn't end up dropping everything to three words or less like you were hoping, but I dropped some words that were not providing useful information and simplified some phrases.

@typescript-bot
Copy link
Copy Markdown
Contributor

Updated numbers for you here from 3c29495.

Comparison details 📊
master #45717 diff
Batch compilation
Memory usage (MiB) 57.1 51.7 -9.4%
Type count 8983 9729 +8%
Assignability cache size 1191 1495 +26%
Language service
Samples taken 2085 2160 +4%
Identifiers in tests 2085 2160 +4%
getCompletionsAtPosition
    Mean duration (ms) 158.7 162.8 +2.6%
    Mean CV 10.9% 11.0%
    Worst duration (ms) 262.4 377.1 +43.7% 🔸
    Worst identifier userid _
getQuickInfoAtPosition
    Mean duration (ms) 151.8 155.8 +2.6%
    Mean CV 11.0% 11.0% +0.2%
    Worst duration (ms) 265.7 377.1 +41.9% 🔸
    Worst identifier isSymbol extractChainTypes

Looks like there were a couple significant differences—take a look at worst-case duration for getting completions at a position and worst-case duration for getting quick info at a position to make sure everything looks ok.

@jgonggrijp
Copy link
Copy Markdown
Contributor

Still an improvement, works for me. 👍

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Sounds good @jgonggrijp, thanks! Unfortunately per the below screenshot of typescript-bot's comment around merging I think you need to approve the most recent commit for me to be able to merge this; if you wouldn't mind doing that whenever you have a chance, I'd appreciate it!

image

It looks like there might be a button to more thoroughly request your reapproval, too, let me try it quick...

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

There's a button I've tried before, but as far as I can tell clicking it doesn't do anything, which seems odd. Sorry if I caused multiple emails to be sent to you by clicking on it @jgonggrijp.

image

@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 Jun 28, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

@reubenrybnik Everything looks good here. Great job! I am ready to merge this PR on your behalf.

If you'd like that to happen, please post a comment saying:

Ready to merge

and I'll merge this PR almost instantly. Thanks for helping out! ❤️

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot merged commit bce8dab into DefinitelyTyped:master Jun 28, 2020
ngbrown pushed a commit to ngbrown-forks/DefinitelyTyped that referenced this pull request Jul 11, 2020
…rray Tests - Type Extractors by @reubenrybnik

* Adding type extractors and updating existing tests to use them.

* Improving handling of mixed-iterability types by simplifying the Underscore and chain functions to a single overload.

* Updating TypeOfCollection to check against List and Dictionary separately instead of using Collection since using the latter behaves oddly with JQuery objects.

* Renaming a variable to something slightly more friendly.

* Renaming variables in tests.
danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
…rray Tests - Type Extractors by @reubenrybnik

* Adding type extractors and updating existing tests to use them.

* Improving handling of mixed-iterability types by simplifying the Underscore and chain functions to a single overload.

* Updating TypeOfCollection to check against List and Dictionary separately instead of using Collection since using the latter behaves oddly with JQuery objects.

* Renaming a variable to something slightly more friendly.

* Renaming variables in tests.
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: Worse typescript-bot determined that this PR has a negative impact on 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.

3 participants