-
Notifications
You must be signed in to change notification settings - Fork 734
Ref Typings #2885
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
Ref Typings #2885
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Wrote few small comments..
const customSlider = useRef<typeof Incubator.Slider>(); | ||
const negativeSlider = useRef<typeof Incubator.Slider>(); | ||
const rangeSlider = useRef<typeof Incubator.Slider>(); | ||
const slider = useRef<Incubator.SliderRef>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to pass null here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -213,4 +213,5 @@ GradientSlider.displayName = 'GradientSlider'; | |||
GradientSlider.types = GradientSliderTypes; | |||
|
|||
// eslint-disable-next-line max-len | |||
export default asBaseComponent<GradientSliderProps, typeof GradientSlider>(forwardRef(asSliderGroupChild(forwardRef(GradientSlider)))); | |||
// @ts-expect-error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why we have an error here?
If it's too complicated we can solve it another time..
Description
Added RefInterface to the our forwardRef function. Adding this generic sets the type of the ref to the specific interface so when passing ref to a one of our components it will show a ts error when passing an incompatible interface ref.
Changelog
Added generic typings to the forwardRef and in the asBaseComponent usage.
Additional info
None