Skip to content

fix: simplify CustomAccordion item type casting in VotesDetails once ui-components-library is updated #2319

@coderabbitai

Description

@coderabbitai

Context

In web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx, the CustomAccordion component from @kleros/ui-components-library declares two AccordionItem types. TypeScript resolves to the narrower type, causing type errors when passing accordionItems directly to StyledAccordion.

As a workaround, the following cast was introduced:

<StyledAccordion items={accordionItems as unknown as CustomAccordionItem[]} />

The CustomAccordionItem type alias was also added with an explanatory comment:

//Current ui-components-library version declares two AccordionItem types.
//TypeScript resolves to the narrower type, so we get type errors here.
//Updating to the latest version of the library should allows to simplify this.
type CustomAccordionItem = React.ComponentProps<typeof CustomAccordion>["items"][number];

Action Required

Once @kleros/ui-components-library is updated:

  1. Check if the duplicate AccordionItem type issue has been resolved.
  2. If resolved, simplify the type cast — remove the CustomAccordionItem alias and pass accordionItems directly.
  3. If the issue is still not resolved after the library update, it must be fixed in the library itself as soon as possible.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions