[@types/underscore] Collection and Array Tests - Max, Min, and Size#46240
Conversation
|
@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": 46240,
"author": "reubenrybnik",
"owners": [
"borisyankov",
"jbaldwin",
"ccurrens",
"confususs",
"jgonggrijp",
"ffflorian",
"regevbr",
"peterblazejewicz",
"reubenrybnik"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "ee9bd2d",
"headCommitOid": "ee9bd2d6b6bd40ee9d75658cf2e05f7a055b4e8a",
"mergeIsRequested": true,
"stalenessInDays": 0,
"lastPushDate": "2020-07-25T02:24:19.000Z",
"lastCommentDate": "2020-07-25T22:25:09.000Z",
"maintainerBlessed": false,
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46240/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-25T20:40:00.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 |
|
My company's solution does unfortunately end up with several new errors due to |
|
👋 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.
The types could be more accurate by exploiting IterateeResult. That said, they are already more accurate than they were and I'd consider this good enough. It's also great to get rid of such a verbose bunch of overloads again.
So I'm suggesting changes, but I'm also fine with it if you want to leave it at this.
…mbers since several other types can be comparable in ways that work with these functions.
|
@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? |
jgonggrijp
left a comment
There was a problem hiding this comment.
I agree that the latest change is an improvement.
Regarding the problems with the sophisticated type I suggested, I think the principle is still sound, but I defined NumberComparable too narrowly. The JS runtime will try very hard to coerce the operand; if valueOf results in a string instead of a number, then that string will be coerced to number after all (even though that results in NaN in many cases). So it will probably work better if you change it accordingly:
type NumberComparable = {
valueOf(): number | string | boolean | null | undefined;
} | {
[Symbol.toPrimitive](): number | string | boolean | null | undefined;
} | {
toString(): string;
};But I have no objection against leaving it as is.
|
Thanks @jgonggrijp! I'm a little worried at this point that this may be a potential maintenance headache due to possible future additional implementations that might make an object comparable along with this also suffering from the |
|
Ready to merge |
|
I just published |
…rray Tests - Max, Min, and Size by @reubenrybnik * Updating type definitions for max, min, and size and adding tests. * Allowing max and min iteratees to return any value instead of only numbers since several other types can be comparable in ways that work with these functions.
…rray Tests - Max, Min, and Size by @reubenrybnik * Updating type definitions for max, min, and size and adding tests. * Allowing max and min iteratees to return any value instead of only numbers since several other types can be comparable in ways that work with these functions.
npm test.)npm run lint package-name(ortscif notslint.jsonis present).This PR continues the planned set that will together add up to #45201 and includes the following changes:
min,max, andsize.minandmaxby updating them to useIteratee.maxandminto always includenumberto cover the possibilities of +/-Infinity for empty collections.Tgeneric fromUnderscoreStatic.size.Underscoreand_Chainversions ofmaxandminto work with both Lists and Dictionaries to partially fix Underscore collections functions should take objects #20623.