react-native-slider icon indicating copy to clipboard operation
react-native-slider copied to clipboard

Typings (for typescript)

Open finnmerlett opened this issue 4 years ago • 2 comments

Can you add typings for typescript? I would love to use this in my project, but without types it's really annoying. Many thanks!

finnmerlett avatar May 05 '20 11:05 finnmerlett

you can add your own typings in the mean time by declaring the module:

  • create a slider.d.ts file at the top of your project
  • declare the module like so:
declare module 'react-native-slider' {
  import { ViewStyle } from 'react-native'

  interface ISlider {
    minimumValue?: number
    maximumValue?: number
    disabled?: boolean
    value?: number
    step?: number
    minimumTrackTintColor?: string
    maximumTrackTintColor?: string
    thumbTintColor?: string
    thumbTouchSize?: {
      width: number
      height: number
    }

    onValueChange?: (value: number) => void
    onSlidingStart?: (value: number) => void
    onSlidingComplete?: (value?: number) => void

    style?: ViewStyle
    trackStyle?: ViewStyle
    thumbStyle?: ViewStyle
    thumbImage?: number

    debugTouchArea?: boolean
    animateTransitions?: boolean
    animationType?: 'spring' | 'timing'
    animationConfig?: any
  }

  export default function Slider(props: ISlider): any
}

ajsmth avatar Jan 18 '21 05:01 ajsmth

Actually, it is not a solution, it would be better to have the types in the library.

amerllica avatar Jul 19 '22 13:07 amerllica