[@wordpress/data] Fix return value of dispatched actions to be a Promise#60693
Conversation
|
@sirbrillig 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. You can test the changes of this PR in the Playground. 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": 60693,
"author": "sirbrillig",
"headCommitOid": "66189e99b4fbbaf7f28f07b5e533451b695c8e31",
"mergeBaseOid": "595c471bd4aefa44a5d0ee49c4d73f373c319d18",
"lastPushDate": "2022-06-08T22:28:20.000Z",
"lastActivityDate": "2022-06-20T19:32:54.000Z",
"mergeOfferDate": "2022-06-16T16:24:22.000Z",
"mergeRequestDate": "2022-06-20T19:32:54.000Z",
"mergeRequestUser": "sirbrillig",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Well-liked by everyone",
"pkgInfo": [
{
"name": "wordpress__data",
"kind": "edit",
"files": [
{
"path": "types/wordpress__data/index.d.ts",
"kind": "definition"
},
{
"path": "types/wordpress__data/wordpress__data-tests.tsx",
"kind": "test"
}
],
"owners": [
"dsifford",
"sirreal"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "dmsnell",
"date": "2022-06-16T16:23:34.000Z",
"isMaintainer": false
},
{
"type": "stale",
"reviewer": "sarayourfriend",
"date": "2022-06-07T21:03:08.000Z",
"abbrOid": "6353f1f"
},
{
"type": "stale",
"reviewer": "sirreal",
"date": "2022-06-06T19:34:21.000Z",
"abbrOid": "e4798c4"
}
],
"mainBotCommentID": 1147822909,
"ciResult": "pass"
} |
|
🔔 @dsifford @sirreal — please review this PR in the next few days. Be sure to explicitly select |
|
@sirbrillig The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
|
Inspecting the JavaScript source for this package found some properties that are not in the .d.ts files. wordpress__data (unpkg)was missing the following properties:
|
|
@sirreal 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? |
|
Updated to make this less breaking thanks to an excellent idea by @sarayourfriend. |
|
@sirbrillig The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
|
@sirbrillig The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
Co-authored-by: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com>
|
@sirbrillig The CI build failed! Please review the logs for more information. Once you've pushed the fixes, the build will automatically re-run. Thanks! Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review. |
|
@sarayourfriend, @sirreal 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? |
sarayourfriend
left a comment
There was a problem hiding this comment.
We'll want to add a test that passes false for DoEnsurePromise as well.
|
Would this be simpler if we relaxed the type parameters? Record<string, <T extends Promise<any> | any>(...args: readonly any[]) => T>this captures the |
Making it simpler sounds nice, but when I try using that type in actual code, the type of an action without an explicit generic becomes For reference, here's the code I'm using to test these changes. Currently it has an explicit generic, but IMO it should work without a generic at all because the default behavior is to return a Promise. |
dmsnell
left a comment
There was a problem hiding this comment.
Let's fly with this. Seems sufficient enough; thanks for addressing the promise issue.
|
@sirbrillig: Everything looks good here. I am ready to merge this PR (at 66189e9) on your behalf whenever you think it's ready. If you'd like that to happen, please post a comment saying:
and I'll merge this PR almost instantly. Thanks for helping out! ❤️ |
|
Ready to merge |
See https://github.com/WordPress/gutenberg/blob/6aef6e6b9b5cf2f5aeff6145cd24181edf0d43f0/packages/data/README.md#user-content-dispatch "Note: Action creators returned by the dispatch will return a promise when they are called." This was previously fixed in the DT types here: DefinitelyTyped/DefinitelyTyped#60693
…ad of void (#72841) * Change DispatchFromMap to return Promise<void> instead of void See https://github.com/WordPress/gutenberg/blob/6aef6e6b9b5cf2f5aeff6145cd24181edf0d43f0/packages/data/README.md#user-content-dispatch "Note: Action creators returned by the dispatch will return a promise when they are called." This was previously fixed in the DT types here: DefinitelyTyped/DefinitelyTyped#60693 * Void dispatched Promise to useEffect cleanup in CreateSiteError
Please fill in this template.
npm test <package to test>.If changing an existing definition: