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

[data] Export the type for the combineReducers export #43516

Merged
merged 2 commits into from
Aug 23, 2022
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
4 changes: 4 additions & 0 deletions packages/data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ const store = createReduxStore( 'my-shop', {
register( store );
```

_Type_

- `import('./types').combineReducers`

_Parameters_

- _reducers_ `Object`: An object whose values correspond to different reducing functions that need to be combined into one.
Expand Down
5 changes: 3 additions & 2 deletions packages/data/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import combineReducers from 'turbo-combine-reducers';
import turboCombineReducers from 'turbo-combine-reducers';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,6 +43,7 @@ export { plugins };
* The combineReducers helper function turns an object whose values are different
* reducing functions into a single reducing function you can pass to registerReducer.
*
* @type {import('./types').combineReducers}
* @param {Object} reducers An object whose values correspond to different reducing
* functions that need to be combined into one.
*
Expand Down Expand Up @@ -77,7 +78,7 @@ export { plugins };
* @return {Function} A reducer that invokes every reducer inside the reducers
* object, and constructs a state object with the same shape.
*/
export { combineReducers };
export const combineReducers = turboCombineReducers;

/**
* Given a store descriptor, returns an object of the store's selectors.
Expand Down
8 changes: 8 additions & 0 deletions packages/data/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* External dependencies
*/
// eslint-disable-next-line no-restricted-imports
import type { combineReducers as reduxCombineReducers } from 'redux';

type MapOf< T > = { [ name: string ]: T };

export type ActionCreator = Function | Generator;
Expand Down Expand Up @@ -97,3 +103,5 @@ type SelectorsOf< Config extends AnyConfig > = Config extends ReduxStoreConfig<
>
? { [ name in keyof Selectors ]: Function }
: never;

export type combineReducers = typeof reduxCombineReducers;