[@types/underscore] Fix for augmented list collection type extraction#47539
Conversation
…d dictionary types from an augmented list type.
|
@reubenrybnik Thank you for submitting this PR! This is a live comment which I will keep updated. 1 package in this PRCode 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": 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
} |
|
🔔 @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. |
jgonggrijp
left a comment
There was a problem hiding this comment.
This looks good to me. Nice to see one of your PRs again, welcome back!
…roperty name to match the interface it's supposed to be more or less a copy of.
|
@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 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:
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.) |
|
Ready to merge |
|
I just published |
…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.
npm test.)npm run lint package-name(ortscif notslint.jsonis present).tslint.jsoncontaining{ "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.
pickandomit).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.