Skip to content

Commit

Permalink
fix(BaseSlider): replace ts-expect error with a type assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Dec 3, 2024
1 parent 6017c26 commit c23285d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/components/Slider/BaseSlider/BaseSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ import './BaseSlider.scss';

const b = block('base-slider');

type BaseSliderProps = {stateModifiers: StateModifiers} & Omit<
SliderProps<number | [number, number]>,
type BaseSliderProps<T = number | number[]> = {stateModifiers: StateModifiers} & Omit<
SliderProps<T>,
'classNames' | 'prefixCls' | 'className' | 'pushable' | 'keyboard'
>;

export const BaseSlider = React.forwardRef<SliderRef, BaseSliderProps>(function BaseSlider(
{stateModifiers, ...otherProps}: BaseSliderProps,
ref: React.ForwardedRef<SliderRef>,
{stateModifiers, ...otherProps},
ref,
) {
return (
// @ts-expect-error Slider value type is (number | number[]) but we use (number | [number, number])
<Slider
{...otherProps}
ref={ref}
Expand All @@ -37,4 +36,4 @@ export const BaseSlider = React.forwardRef<SliderRef, BaseSliderProps>(function
keyboard={true}
/>
);
});
}) as <T>(p: BaseSliderProps<T> & {ref?: React.Ref<SliderRef>}) => React.ReactElement;
2 changes: 1 addition & 1 deletion src/components/Slider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export type SliderProps<ValueType = number | [number, number]> = {
/** The control's tabIndex attribute */
tabIndex?: ValueType;
/** Ref to Slider's component props of focus and blur */
apiRef?: React.RefObject<BaseSliderRefType>;
apiRef?: React.Ref<BaseSliderRefType>;
'aria-label'?: string | [string, string];
'aria-labelledby'?: string | [string, string];
id?: string;
Expand Down

0 comments on commit c23285d

Please sign in to comment.