Skip to content

Commit

Permalink
Core data: Fix some typing issues (#39212)
Browse files Browse the repository at this point in the history
Part of #39211

Fixes a few small issues with the JSDoc types in @wordpress/core-data.

 - `undefined` was the wrong return type for the given files. removing that type to remove the error and leaving them untyped.
 - acknowledge that the `undoIgnore` parameter is optional for `editEntityRecord`
 - return type of `__experimentalBatch` is a function that returns a `Promise`, not a `Promise`

Co-authored-by: Adam Zielinski <[email protected]>
  • Loading branch information
dmsnell and adamziel authored Mar 4, 2022
1 parent 17479ca commit baeb329
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 30 deletions.
10 changes: 1 addition & 9 deletions docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ _Parameters_
- _recordId_ `number`: Record ID of the edited entity record.
- _edits_ `Object`: The edits.
- _options_ `Object`: Options for the edit.
- _options.undoIgnore_ `boolean`: Whether to ignore the edit in undo history or not.
- _options.undoIgnore_ `[boolean]`: Whether to ignore the edit in undo history or not.

_Returns_

Expand Down Expand Up @@ -680,10 +680,6 @@ _Returns_
Action triggered to redo the last undoed
edit to an entity record, if any.

_Returns_

- `undefined`:

### saveEditedEntityRecord

Action triggered to save an entity record's edits.
Expand Down Expand Up @@ -713,8 +709,4 @@ _Parameters_
Action triggered to undo the last edit to
an entity record, if any.

_Returns_

- `undefined`:

<!-- END TOKEN(Autogenerated actions|../../../packages/core-data/src/actions.js) -->
10 changes: 1 addition & 9 deletions packages/core-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ _Parameters_
- _recordId_ `number`: Record ID of the edited entity record.
- _edits_ `Object`: The edits.
- _options_ `Object`: Options for the edit.
- _options.undoIgnore_ `boolean`: Whether to ignore the edit in undo history or not.
- _options.undoIgnore_ `[boolean]`: Whether to ignore the edit in undo history or not.

_Returns_

Expand Down Expand Up @@ -214,10 +214,6 @@ _Returns_
Action triggered to redo the last undoed
edit to an entity record, if any.

_Returns_

- `undefined`:

### saveEditedEntityRecord

Action triggered to save an entity record's edits.
Expand Down Expand Up @@ -247,10 +243,6 @@ _Parameters_
Action triggered to undo the last edit to
an entity record, if any.

_Returns_

- `undefined`:

<!-- END TOKEN(Autogenerated actions|src/actions.js) -->

## Selectors
Expand Down
20 changes: 8 additions & 12 deletions packages/core-data/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ export const deleteEntityRecord = (
* Returns an action object that triggers an
* edit to an entity record.
*
* @param {string} kind Kind of the edited entity record.
* @param {string} name Name of the edited entity record.
* @param {number} recordId Record ID of the edited entity record.
* @param {Object} edits The edits.
* @param {Object} options Options for the edit.
* @param {boolean} options.undoIgnore Whether to ignore the edit in undo history or not.
* @param {string} kind Kind of the edited entity record.
* @param {string} name Name of the edited entity record.
* @param {number} recordId Record ID of the edited entity record.
* @param {Object} edits The edits.
* @param {Object} options Options for the edit.
* @param {boolean} [options.undoIgnore] Whether to ignore the edit in undo history or not.
*
* @return {Object} Action object.
*/
Expand Down Expand Up @@ -345,8 +345,6 @@ export const editEntityRecord = (
/**
* Action triggered to undo the last edit to
* an entity record, if any.
*
* @return {undefined}
*/
export const undo = () => ( { select, dispatch } ) => {
const undoEdit = select.getUndoEdit();
Expand All @@ -363,8 +361,6 @@ export const undo = () => ( { select, dispatch } ) => {
/**
* Action triggered to redo the last undoed
* edit to an entity record, if any.
*
* @return {undefined}
*/
export const redo = () => ( { select, dispatch } ) => {
const redoEdit = select.getRedoEdit();
Expand Down Expand Up @@ -607,8 +603,8 @@ export const saveEntityRecord = (
* `saveEntityRecord`, `saveEditedEntityRecord`, and
* `deleteEntityRecord`.
*
* @return {Promise} A promise that resolves to an array containing the return
* values of each function given in `requests`.
* @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return
* values of each function given in `requests`.
*/
export const __experimentalBatch = ( requests ) => async ( { dispatch } ) => {
const batch = createBatch();
Expand Down

0 comments on commit baeb329

Please sign in to comment.