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

Type error: 'DraggableList' cannot be used as a JSX component #70

Open
JstnMcBrd opened this issue Aug 6, 2024 · 0 comments
Open

Type error: 'DraggableList' cannot be used as a JSX component #70

JstnMcBrd opened this issue Aug 6, 2024 · 0 comments

Comments

@JstnMcBrd
Copy link

JstnMcBrd commented Aug 6, 2024

The types in files/dist/src/index.d.ts appear to be incompatible with React.

function Test() {
  return <DraggableList />
}
'DraggableList' cannot be used as a JSX component.
  Its instance type 'DraggableList<unknown, unknown, Component<Partial<TemplateProps<unknown, unknown>>, {}, any>>' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'Element' is not assignable to type 'ReactNode'.
        Property 'children' is missing in type 'Element' but required in type 'ReactPortal'.

This is because on the DraggableList type definition, render() returns JSX.Element.

// node_modules/react-draggable-list/dist/src/index.d.ts
export default class DraggableList<...> extends React.Component<...> {
  render(): React.JSX.Element;
}

But on React's component types, it returns ReactNode.

// node_modules/@types/react/files/index.d.ts
declare namespace React {
  class Component<...> {
    render(): ReactNode;
  }
}

I suggest explicitly defining the return type of render() on src/index.tsx#L566.

-  render() {
+  render(): ReactNode {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant