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

TypeScript: Spreading props creates ref type bug #187

Open
Sir-hennihau opened this issue Aug 12, 2021 · 0 comments
Open

TypeScript: Spreading props creates ref type bug #187

Sir-hennihau opened this issue Aug 12, 2021 · 0 comments

Comments

@Sir-hennihau
Copy link

What is the current behavior?
Prop types are bugged. Spreading its props into itself gives a weird error about ref.

Type '{ children: ReactNode; wrapperProps: { renderer: ({ elementRef, style, ...restProps }: PropsWithChildren<ElementPropsWithElementRef<HTMLDivElement>>) => Element; }; ... 409 more ...; onUpdate?: ((scrollValues: ScrollState, prevScrollState: ScrollState) => void) | undefined; }' is not assignable to type 'IntrinsicClassAttributes<Scrollbar>'.
  Types of property 'ref' are incompatible.
    Type 'LegacyRef<HTMLDivElement> | undefined' is not assignable to type 'LegacyRef<Scrollbar> | undefined'.
      Type '(instance: HTMLDivElement | null) => void' is not assignable to type 'LegacyRef<Scrollbar> | undefined'.
        Type '(instance: HTMLDivElement | null) => void' is not assignable to type '(instance: Scrollbar | null) => void'.
          Types of parameters 'instance' and 'instance' are incompatible.
            Type 'Scrollbar | null' is not assignable to type 'HTMLDivElement | null'.
              Type 'Scrollbar' is missing the following properties from type 'HTMLDivElement': align, addEventListener, removeEventListener, accessKey, and 227 more.  TS2322

Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than react-scrollbars-custom. Paste the link to your JSFiddle or CodeSandbox example below:

import ReactScrollbarsCustom, { ScrollbarProps } from "react-scrollbars-custom";

export const CustomScrollbars = (props: ScrollbarProps) => {
    return <ReactScrollbarsCustom {...props}></ReactScrollbarsCustom>;
};

What is the expected behavior?
No Typescript error

A little about versions:

  • OS: Ubuntu
  • React: 17.0.2
  • react-scrollbars-custom: 4.0.25
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