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 when passing SliderElementProps to SliderElement #280

Open
2 tasks done
sir-dunxalot opened this issue Jun 25, 2024 · 0 comments
Open
2 tasks done

Type error when passing SliderElementProps to SliderElement #280

sir-dunxalot opened this issue Jun 25, 2024 · 0 comments

Comments

@sir-dunxalot
Copy link

sir-dunxalot commented Jun 25, 2024

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When you pass props with type SliderElementProps to SliderElement (using the spread operator)...

interface SliderFieldProps extends SliderElementProps {}

const SliderField = (props: SliderFieldProps) => {
  return <SliderElement {...props} />; // Error
};

... Typescript throws an error because of mismatching types:

Type 'RefObject<HTMLSpanElement>' is not assignable to type 'RefObject<HTMLDivElement>'.
          Property 'align' is missing in type 'HTMLSpanElement' but required in type 'HTMLDivElement'.

Expected behavior 🤔

No Typescript error is shown. The user is able to pass props of type SliderElementProps to the SliderElement component.

Steps to reproduce 🕹

Steps to reproduce:

  1. Go to https://codesandbox.io/p/devbox/slider-type-bug-csnndp
  2. View App.tsx
  3. On line 7, a type error will be visible (if the error isn't visible, try making a change to the file. Sometimes devbox doesn't show type errors unless you're editing)
image
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