Skip to content

[@types/underscore] Fix for augmented list collection type extraction#47539

Merged
typescript-bot merged 2 commits intoDefinitelyTyped:masterfrom
reubenrybnik:augmented-list-collection-type-fix
Sep 14, 2020
Merged

[@types/underscore] Fix for augmented list collection type extraction#47539
typescript-bot merged 2 commits intoDefinitelyTyped:masterfrom
reubenrybnik:augmented-list-collection-type-fix

Conversation

@reubenrybnik
Copy link
Copy Markdown
Contributor

@reubenrybnik reubenrybnik commented Sep 12, 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: <>
  • Include tests for your changes
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }. If for reason the any rule need to be disabled, disable it for that line using // tslint:disable-next-line [ruleName] and not for whole package so that the need for disabling can be reviewed.

This fixes an issue where TypeOfCollection is extracting both the list and dictionary types from augmented list types. In cases where Underscore functions take a collection, Underscore prefers list implementations and falls back to dictionary implementations; this keeps TypeOfCollection consistent with that behavior while still allowing TypeOfDictionary to treat lists as objects for Object functions that don't handle lists differently from other objects (e.g. pick and omit).

I ran into this when updating the codebase of the company that I work for to TS4.0 - after upgrading, the type JQuery<HTMLElement> started being interpreted as both a list and a dictionary. I attempted to replicate this behavior in tests by using interfaces (going so far as to try generics and an interface with the same name as a namespace) but was unable to do so. However, the use of type literals still allowed for a comparable repro to help prevent regressions in the future.

…d dictionary types from an augmented list type.
@typescript-bot typescript-bot added 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 Sep 12, 2020
@typescript-bot
Copy link
Copy Markdown
Contributor

typescript-bot commented Sep 12, 2020

@reubenrybnik Thank you for submitting this PR!

This is a live comment which I will keep updated.

1 package in 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": 47539,
  "author": "reubenrybnik",
  "owners": [
    "borisyankov",
    "jbaldwin",
    "ccurrens",
    "confususs",
    "jgonggrijp",
    "ffflorian",
    "regevbr",
    "peterblazejewicz",
    "reubenrybnik"
  ],
  "dangerLevel": "ScopedAndTested",
  "headCommitAbbrOid": "87bfd59",
  "headCommitOid": "87bfd597e482de1b4031b3e8bfa87eeca9d4ede3",
  "mergeIsRequested": true,
  "stalenessInDays": 0,
  "lastPushDate": "2020-09-14T16:10:22.000Z",
  "lastCommentDate": "2020-09-14T18:18:55.000Z",
  "maintainerBlessed": false,
  "reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/47539/files",
  "hasMergeConflict": false,
  "authorIsOwner": true,
  "isFirstContribution": false,
  "popularityLevel": "Popular",
  "newPackages": [],
  "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-09-14T18:14:40.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
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 #47539 diff
Batch compilation
Memory usage (MiB) 68.3 68.4 +0.2%
Type count 14711 12847 -13%
Assignability cache size 1754 1923 +10%
Language service
Samples taken 8350 8401 +1%
Identifiers in tests 8350 8401 +1%
getCompletionsAtPosition
    Mean duration (ms) 200.8 200.5 -0.2%
    Mean CV 6.6% 6.6%
    Worst duration (ms) 409.1 420.1 +2.7%
    Worst identifier recordStringReducer _
getQuickInfoAtPosition
    Mean duration (ms) 196.4 195.8 -0.3%
    Mean CV 6.8% 6.8% -0.4%
    Worst duration (ms) 477.4 445.5 -6.7%
    Worst identifier extractChainTypes extractChainTypes

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 Sep 12, 2020
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.

This looks good to me. Nice to see one of your PRs again, welcome back!

@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 Sep 14, 2020
…roperty name to match the interface it's supposed to be more or less a copy of.
@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 Sep 14, 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?

@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 Sep 14, 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! ❤️

(@borisyankov, @jbaldwin, @ccurrens, @confususs, @jgonggrijp, @ffflorian, @regevbr, @peterblazejewicz: you can do this too.)

@reubenrybnik
Copy link
Copy Markdown
Contributor Author

Ready to merge

@typescript-bot typescript-bot merged commit a459cbd into DefinitelyTyped:master Sep 14, 2020
@reubenrybnik reubenrybnik deleted the augmented-list-collection-type-fix branch September 14, 2020 18:19
@typescript-bot
Copy link
Copy Markdown
Contributor

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

danielrearden pushed a commit to danielrearden/DefinitelyTyped that referenced this pull request Sep 22, 2020
…d list collection type extraction by @reubenrybnik

* Fixing an issue where TypeOfCollection is extracting both the list and dictionary types from an augmented list type.

* Adding a missing semicolon and updating the augmented list non-list property name to match the interface it's supposed to be more or less a copy of.
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.

3 participants