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

Typings (for typescript) #180

Open
finnmerlett opened this issue May 5, 2020 · 2 comments
Open

Typings (for typescript) #180

finnmerlett opened this issue May 5, 2020 · 2 comments

Comments

@finnmerlett
Copy link

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

@ajsmth
Copy link

ajsmth commented Jan 18, 2021

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
}

@amerllica
Copy link

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

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

3 participants