[Bluebird] support then -> static .all -> then#46720
[Bluebird] support then -> static .all -> then#46720patricklx wants to merge 5 commits intoDefinitelyTyped:masterfrom
Conversation
|
@patricklx 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
Once every item on this list is checked, I'll ask you for permission to merge and publish the changes. InactiveThis PR has been inactive for 31 days — it is considered abandoned! Diagnostic Information: What the bot saw about this PR{
"type": "info",
"now": "-",
"pr_number": 46720,
"author": "patricklx",
"owners": [
"lhecker"
],
"dangerLevel": "ScopedAndTested",
"headCommitAbbrOid": "bc57437",
"headCommitOid": "bc574372c5fd103179e12c3e1ccfcdcff5e37fb1",
"mergeIsRequested": false,
"stalenessInDays": 31,
"lastPushDate": "2020-08-20T12:39:37.000Z",
"lastCommentDate": "2020-08-21T09:40:46.000Z",
"maintainerBlessed": false,
"reviewLink": "https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46720/files",
"hasMergeConflict": false,
"authorIsOwner": false,
"isFirstContribution": false,
"popularityLevel": "Popular",
"newPackages": [],
"packages": [
"bluebird"
],
"files": [
{
"path": "types/bluebird/bluebird-tests.ts",
"kind": "test",
"package": "bluebird"
},
{
"path": "types/bluebird/index.d.ts",
"kind": "definition",
"package": "bluebird"
}
],
"hasDismissedReview": false,
"ciResult": "fail",
"ciUrl": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/bc574372c5fd103179e12c3e1ccfcdcff5e37fb1/checks?check_suite_id=1075551965",
"reviewersWithStaleReviews": [
{
"reviewedAbbrOid": "e3f6ba0",
"reviewer": "lhecker",
"date": "2020-08-19T10:35:25Z"
},
{
"reviewedAbbrOid": "f7d9f65",
"reviewer": "lhecker",
"date": "2020-08-17T11:58:16Z"
},
{
"reviewedAbbrOid": "f4de064",
"reviewer": "lhecker",
"date": "2020-08-13T17:04:32Z"
}
],
"approvalFlags": 0,
"isChangesRequested": false
} |
|
🔔 @lhecker — please review this PR in the next few days. Be sure to explicitly select |
|
Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files. bluebird (unpkg)was missing the following properties:
as well as these 1 other properties...pending |
|
👋 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. |
There was a problem hiding this comment.
Can you explain what this PR attempts to solve? Did you perhaps accidentally specify your tuple incorrectly?
Because the example you gave works just fine for me:
const x: [string, number] = ["hello", 10]; // correct tuple declaration (important!)
Bluebird.resolve(x).all().then(([x1, x2]) => {
let y1: string = x1;
let y2: number = x2;
});("Requesting changes" so the bot knows what's up.)
|
@patricklx One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits or comments. If you disagree with the reviewer's comments, you can "dismiss" the review using GitHub's review UI. Thank you! |
|
Ah nevermind I figured it out... You need two |
There was a problem hiding this comment.
Finally I'd like to ask you to add a unit test about here.
I used the following code for testing (feel free to use it as well):
Bluebird.resolve(["", 0] as [string, number])
.then(([x1, x2]) => [x1, x2])
.then(([x1, x2]) => {
const y1: string = x1;
const y2: number = x2;
});| * The new promise will be rejected or resolved depending on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. | ||
| */ | ||
| // Based on PromiseLike.then, but returns a Bluebird instance. | ||
| // to support static .all |
There was a problem hiding this comment.
This comment is not very descriptive / not very helpful. You can remove it.
| then<T1, T2>(onFulfill?: (value: R) => Resolvable<[T1, T2]>, onReject?: (error: any) => Resolvable<[T1, T2]>): Bluebird<[T1, T2]>; | ||
| then<T1, T2, T3>(onFulfill?: (value: R) => Resolvable<[T1, T2, T3]>, onReject?: (error: any) => Resolvable<[T1, T2, T3]>): Bluebird<[T1, T2, T3]>; | ||
| then<T1, T2, T3, T4>(onFulfill?: (value: R) => Resolvable<[T1, T2, T3, T4]>, onReject?: (error: any) => Resolvable<[T1, T2, T3, T4]>): Bluebird<[T1, T2, T3, T4]>; | ||
| then<T1, T2, T3, T4, T5>(onFulfill?: (value: R) => Resolvable<[T1, T2, T3, T4, T5]>, onReject?: (error: any) => Resolvable<[T1, T2, T3, T4, T5]>): Bluebird<[T1, T2, T3, T4, T5]>; |
There was a problem hiding this comment.
- Could you please order these overloads the same way as
.allis overloaded? That is: Descending from the T1-T5 variant down to the T1-T2 one. - Additionally, to make it consistent, I'd like to ask you to please rename
<U>to<T1>below. - The empty newline L66 can also be removed.
|
@lhecker 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? |
|
changed it so it correctly resolves promises |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
Oh I forgot about your PR… The changes look good to me now, but unfortunately you‘re exceeding the line length limit. |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
| Resolvable<T1>, | ||
| Resolvable<T2>, | ||
| Resolvable<T3> | ||
| ], onReject?: (error: any) => [Resolvable<T1>, Resolvable<T2>, Resolvable<T3>]): Bluebird<[T1, T2, T3]>; |
There was a problem hiding this comment.
Nit: You forgot to add line breaks here.
Since it's only a very minor stylistic issue I'll approve your PR regardless. Of course it'd be nice if you fixed it though. 😄
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
The changes look just perfect. 👌 But since yesterday I've spent some time thinking about the underlying reason why you're actually submitting this change... Because if I change my sample code slightly to declare tuples consistently the typings work without any changes: function makePair<T1, T2>(x: T1, y: T2): [T1, T2] {
return [x, y];
}
Bluebird.resolve(makePair("", 0))
.then(([x1, x2]) => makePair(x1, x2))
.then(([x1, x2]) => {
let y1: string = x1;
let y2: number = x2;
});The above code will compile just fine with the current Bluebird typings, since we're always declaring tuples properly. |
|
Right, the test was not correct. But i now wonder if this changes are correct. Since it actually should not have passed. Since the array would contain the Promise in the last then. I guess i need to add something more to the static .all. something with resolvable. |
|
FYI The test currently completes successfully even without any changes to the typings. |
|
true, because of |
| }); | ||
|
|
||
| Bluebird.resolve() | ||
| .then(() => ["", Bluebird.resolve(0)]) |
There was a problem hiding this comment.
You're not declaring a tuple here (which was a point I made earlier).
e.g. `Promise.resolve([x1, x2]).all().then([x1, x2])`
|
Yeah I think I get your point, but I'm honestly not entirely sure if this PR presents a good idea anymore... |
|
To make a specific example for my previous comment: After we merged this PR, the static |
|
like this then? |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
@patricklx The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! |
|
Using variadic tuple types we could simplify a lot of the redundant declarations. |
|
@patricklx I haven't seen any activity on this PR in more than 3 weeks, and this PR currently has problems that prevent it from being merged. The PR will be closed in a week if the issues aren't addressed. |
|
@patricklx To keep things tidy, we have to close PRs that aren't mergeable and don't have activity in the last month. No worries, though — please open a new PR if you'd like to continue with this change. Thank you! |
e.g.
Promise.resolve([x1, x2]).all().then([x1, x2])