Skip to content

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

@JstnMcBrd

Description

@JstnMcBrd

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 {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions