Skip to content

Commit

Permalink
Fixed incorrect type annotations in @wordpress/data (#46881)
Browse files Browse the repository at this point in the history
* Fixed incorrect type annotations in @wordpress/data

* Prettier fix

* Updated @wordpress/data readme
  • Loading branch information
marekdedic authored Feb 7, 2023
1 parent 21da6b3 commit ac2e68f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
8 changes: 8 additions & 0 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,10 @@ import { store as myCustomStore } from 'my-custom-store';
dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
```

_Type_

- `(storeNameOrDescriptor: StoreDescriptor|string) => Object`

_Parameters_

- _storeNameOrDescriptor_ `StoreDescriptor|string`: The store descriptor. The legacy calling convention of passing the store name is also supported.
Expand Down Expand Up @@ -647,6 +651,10 @@ import { store as myCustomStore } from 'my-custom-store';
select( myCustomStore ).getPrice( 'hammer' );
```

_Type_

- `(storeNameOrDescriptor: StoreDescriptor|string) => Object`

_Parameters_

- _storeNameOrDescriptor_ `StoreDescriptor|string`: The store descriptor. The legacy calling convention of passing the store name is also supported.
Expand Down
2 changes: 1 addition & 1 deletion packages/data/src/components/use-dispatch/use-dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useRegistry from '../registry-provider/use-registry';

/**
* @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
* @template StoreConfig
* @template {import('../../types').AnyConfig} StoreConfig
*/
/**
* @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
Expand Down
9 changes: 5 additions & 4 deletions packages/data/src/components/use-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ const renderQueue = createQueue();

/**
* @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
* @template C
* @template {import('../../types').AnyConfig} C
*/
/**
* @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
* @template State,Actions,Selectors
* @template State,Selectors
* @template {Record<string,import('../../types').ActionCreator>} Actions
*/
/** @typedef {import('../../types').MapSelect} MapSelect */
/**
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
* @template T
* @template {MapSelect|StoreDescriptor<any>} T
*/
/** @typedef {import('../../types').MapSelect} MapSelect */

function Store( registry, suspense ) {
const select = suspense ? registry.suspendSelect : registry.select;
Expand Down
4 changes: 4 additions & 0 deletions packages/data/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export const combineReducers = turboCombineReducers;
* ```
*
* @return {Object} Object containing the store's selectors.
*
* @type {(storeNameOrDescriptor: StoreDescriptor|string) => Object}
*/
export const select = defaultRegistry.select;

Expand Down Expand Up @@ -154,6 +156,8 @@ export const suspendSelect = defaultRegistry.suspendSelect;
* dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
* ```
* @return {Object} Object containing the action creators.
*
* @type {(storeNameOrDescriptor: StoreDescriptor|string) => Object}
*/
export const dispatch = defaultRegistry.dispatch;

Expand Down
8 changes: 5 additions & 3 deletions packages/data/src/redux-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import * as metadataActions from './metadata/actions';
/** @typedef {import('../types').DataRegistry} DataRegistry */
/**
* @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor
* @template C
* @template {import('../types').AnyConfig} C
*/
/**
* @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
* @template State,Actions,Selectors
* @template State,Selectors
* @template {Record<string,import('../../types').ActionCreator>} Actions
*/

const trimUndefinedValues = ( array ) => {
Expand Down Expand Up @@ -100,7 +101,8 @@ function createResolversCache() {
* } );
* ```
*
* @template State,Actions,Selectors
* @template State,Selectors
* @template {Record<string,import('../../types').ActionCreator>} Actions
* @param {string} key Unique namespace identifier.
* @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
* describing reducer, actions, selectors,
Expand Down

1 comment on commit ac2e68f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in ac2e68f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4112158138
📝 Reported issues:

Please sign in to comment.