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

Fix TS issue in DroppableContainer #326

Open
3 of 15 tasks
brionmario opened this issue Jan 17, 2025 · 1 comment
Open
3 of 15 tasks

Fix TS issue in DroppableContainer #326

brionmario opened this issue Jan 17, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@brionmario
Copy link
Member

brionmario commented Jan 17, 2025

Describe the issue:

There's a TS issue in the render props of the DroppableContainer when used with TypeScript.

No overload matches this call.
  Overload 1 of 2, '(props: { component: ElementType<any>; } & { component?: ElementType; } & Omit<BoxProps<"div", {}>, "component"> & { children: (props: { dragHandlers: DragHandlers; getDragItemProps: GetDragItemProps; nodes: any[]; }) => ReactNode; nodes: any[]; onOrderChange?: (newOrder: any[]) => void; } & BoxOwnProps<...> & CommonProps & Omit<...>): Element', gave the following error.
    Type '({ nodes, getDragItemProps }: { nodes: PolicyInterface[]; getDragItemProps: GetDragItemProps; }) => JSX.Element[]' is not assignable to type 'ReactNode & ((props: { dragHandlers: DragHandlers; getDragItemProps: GetDragItemProps; nodes: any[]; }) => ReactNode)'.
      Type '({ nodes, getDragItemProps }: { nodes: PolicyInterface[]; getDragItemProps: GetDragItemProps; }) => JSX.Element[]' is not assignable to type 'string & ((props: { dragHandlers: DragHandlers; getDragItemProps: GetDragItemProps; nodes: any[]; }) => ReactNode)'.
        Type '({ nodes, getDragItemProps }: { nodes: PolicyInterface[]; getDragItemProps: GetDragItemProps; }) => JSX.Element[]' is not assignable to type 'string'.
  Overload 2 of 2, '(props: DefaultComponentProps<BoxTypeMap<DroppableContainerProps<ElementType>, "div", Theme>>): Element', gave the following error.
    Type '({ nodes, getDragItemProps }: { nodes: PolicyInterface[]; getDragItemProps: GetDragItemProps; }) => JSX.Element[]' is not assignable to type 'ReactNode & ((props: { dragHandlers: DragHandlers; getDragItemProps: GetDragItemProps; nodes: any[]; }) => ReactNode)'.
      Type '({ nodes, getDragItemProps }: { nodes: PolicyInterface[]; getDragItemProps: GetDragItemProps; }) => JSX.Element[]' is not assignable to type 'string & ((props: { dragHandlers: DragHandlers; getDragItemProps: GetDragItemProps; nodes: any[]; }) => ReactNode)'.
        Type '({ nodes, getDragItemProps }: { nodes: PolicyInterface[]; getDragItemProps: GetDragItemProps; }) => JSX.Element[]' is not assignable to type 'string'.ts(2769)
Box.d.ts(185, 3): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & { component: ElementType<any>; } & { component?: ElementType; } & Omit<BoxProps<"div", {}>, "component"> & { ...; } & BoxOwnProps<...> & CommonProps & Omit<...>'
Box.d.ts(185, 3): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & { component?: ElementType; } & Omit<BoxProps<"div", {}>, "component"> & { children: (props: { dragHandlers: DragHandlers; getDragItemProps: GetDragItemProps; nodes: any[]; }) => ReactNode; nodes: any[]; onOrderChange?: (newOrder: any[]) => void; } & BoxOwnProps<...> & CommonProps & Omit<...>

How to reproduce:

  • Use the DroppableContainer in a TS file.

Expected behavior:

There shouldn't be any TS issues.

Additional context :

  • Affected Package:
    • @oxygen-ui/logger
    • @oxygen-ui/primitives
    • @oxygen-ui/react
    • @oxygen-ui/react-icons
  • Library Version: [e.g., 1.10.0, 2.0.0-alpha]
  • OS:
    • Windows
    • Linux
    • Mac
    • Other
  • Browser:
    • Google Chrome
    • Firefox
    • Safari
    • Microsoft Edge
    • Brave
    • Opera
    • Other
@brionmario brionmario added the bug Something isn't working label Jan 17, 2025
@brionmario brionmario assigned brionmario and unassigned brionmario Jan 17, 2025
@brionmario
Copy link
Member Author

A temporary workaround is added with #327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant