Skip to content

Typescript Support #16

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

Open
bramirez96 opened this issue Apr 5, 2021 · 2 comments
Open

Typescript Support #16

bramirez96 opened this issue Apr 5, 2021 · 2 comments

Comments

@bramirez96
Copy link

I made a module declaration for this library to get it working in typescript. Here it is for anyone else that has this issue, feel free to open a PR and include this in the package, but it works in my project just manually declaring this in a type file:

declare module 'radio-buttons-react-native' {
  import * as React from 'react';
  import { StyleProp, TextStyle, ViewStyle } from 'react-native';
  export type animationTypes = 'zoomIn' | 'pulse' | 'shake' | 'rotate';
  export interface RadioButtonProps<ItemType> {
    /** Defaults to [] */
    data: ItemType[];
    selectedBtn?: (value: ItemType) => void;
    icon?: React.ReactNode;
    /** Defaults to true */
    box?: boolean;
    /** Defaults to -1 */
    initial: number | null;
    /** Defaults to [] */
    animationTypes?: animationTypes[];
    /** Defaults to 500 */
    duration?: number;
    /** Defaults to {} */
    style?: StyleProp<ViewStyle>;
    /** Defaults to {} */
    boxStyle?: StyleProp<ViewStyle>;
    /** Defaults to {} */
    textStyle?: StyleProps<TextStyle>;
    /** Defaults to 18 */
    circleSize?: number;
    /** Defaults to '#03a9f4' */
    activeColor?: string;
    /** Defaults to '#e2e2e2' */
    deactiveColor?: string;
    /** Defaults to '#e1f5fe33' */
    boxActiveBgColor?: string;
    /** Defaults to '#fff' */
    boxDeactiveBgColor?: string;
    /** Defaults to '#383838' */
    textColor?: string;
  }
  export default class RadioButtonRN<T> extends React.Component<
    RadioButtonProps<T>,
    unknown
  > {}
}
@king-d-dev
Copy link

king-d-dev commented Jun 15, 2021

thanks for providing this declaration for typescript users, however, the initial prop value is optional and therefore i suggest you use initial?: number | null; instead. Thank you

@RizkySugiharto
Copy link

what's the name of the file that I should use for adding the ts file?

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