Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect type annotations in @wordpress/data #46881

Merged
merged 3 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ -28,17 +28,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 */

/**
* Custom react hook for retrieving props from registered selectors.
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 @@ -26,11 +26,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 @@ -99,7 +100,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