plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
427 stars 574 forks source link

Wrong parameters in the asyncConnect function #5985

Closed wesleybl closed 1 week ago

wesleybl commented 1 week ago

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

https://github.com/plone/volto/blob/d4d7d58eee9d8b59ba84dd1884d5c3729a412da4/packages/volto/types/helpers/AsyncConnect/index.d.ts#L17

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

https://github.com/plone/volto/blob/e7d6f1c0be483c6560a552bae615b3f80ec21c1e/packages/volto/src/components/manage/Controlpanels/index.tsx#L14-L25

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.