aminebenkeroum / toggle-switch-react-native

Toggle Switch React Native Component works on both iOS and Android
MIT License
235 stars 70 forks source link

TypeScript definition should work #49

Closed thomashagstrom closed 3 years ago

thomashagstrom commented 3 years ago

When installing this lib in a TypeScript project (e.g default Expo project) the included definition does not work.

Should probably look like this (which I'm using):

/// <reference types="node" />

declare module 'toggle-switch-react-native' {
  import React from 'react';
  import {StyleProp, TextStyle, ViewStyle} from 'react-native';

  export type ToggleSwitchProps = {
    isOn: boolean;
    label?: string;
    onColor?: string;
    offColor?: string;
    size?: string;
    labelStyle?: StyleProp<TextStyle>;
    thumbOnStyle?: StyleProp<ViewStyle>;
    thumbOffStyle?: StyleProp<ViewStyle>;
    trackOnStyle?: StyleProp<ViewStyle>;
    trackOffStyle?: StyleProp<ViewStyle>;
    onToggle?: (isOn: boolean) => any;
    icon?: React.ReactNode;
    disabled?: boolean;
    animationSpeed?: number;
    useNativeDriver?: boolean;
    circleColor?: string;
  };

  class ToggleSwitch extends React.Component<ToggleSwitchProps> {}

  export default ToggleSwitch;
}