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

Wrong parameters in the asyncConnect function #5985

Closed
wesleybl opened this issue Apr 26, 2024 · 0 comments · Fixed by #5986
Closed

Wrong parameters in the asyncConnect function #5985

wesleybl opened this issue Apr 26, 2024 · 0 comments · Fixed by #5986
Labels
01 type: bug 30 needs: triage New issue that needs confirmation before work begins

Comments

@wesleybl
Copy link
Member

Describe the bug
The asyncConnect function is declared with 5 required parameters:

export function asyncConnect(asyncItems: any, mapStateToProps: any, mapDispatchToProps: any, mergeProps: any, options: any): (Component: any) => any;

But only the first parameter is required. In many places it is called with only one parameter. For example:

export const Controlpanels = asyncConnect([
{
key: 'controlpanels',
promise: async ({ store: { dispatch } }: any) =>
await dispatch(listControlpanels()),
},
{
key: 'systemInformation',
promise: async ({ store: { dispatch } }: any) =>
await dispatch(getSystemInformation()),
},
])(LoadableControlpanels);

When I run the tests for an addon, I receive the error:

● Test suite failed to run

    node_modules/@plone/volto/src/components/manage/Controlpanels/index.tsx:14:30 - error TS2554: Expected 5 arguments, but got 1.

    14 export const Controlpanels = asyncConnect([
                                    ~~~~~~~~~~~~

      node_modules/@plone/volto/types/helpers/AsyncConnect/index.d.ts:17:47
        17 export function asyncConnect(asyncItems: any, mapStateToProps: any, mapDispatchToProps: any, mergeProps: any, options: any): (Component: any) => any;
                                                         ~~~~~~~~~~~~~~~~~~~~
        An argument for 'mapStateToProps' was not provided.

To Reproduce
Steps to reproduce the behavior:

  1. I ran tests on one of my addons.

Expected behavior
The tests must run without error. When defining parameters, only the first one must be required.

Software (please complete the following information):

Volto 18.0.0-alpha.28
Plone 6.0.10
plone.restapi 9.5.0
CMF 3.3
Zope 5.9
Python 3.11.1 (main, Dec 7 2022, 01:11:34) [GCC 11.3.0]
PIL 9.5.0 (Pillow)

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 type: bug 30 needs: triage New issue that needs confirmation before work begins
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant