maxs15 / react-native-spinkit

A collection of animated loading indicators for React Native
MIT License
2.36k stars 300 forks source link

Support for typescript #105

Closed vTrip closed 4 years ago

vTrip commented 5 years ago

Is it possible to have typescript definitions for this library?

nartc commented 5 years ago

@vTrip

declare module 'react-native-spinkit' {
  import React from 'react';

  export type SpinnerType =
    | 'CircleFlip'
    | 'Bounce'
    | 'Wave'
    | 'WanderingCubes'
    | 'Pulse'
    | 'ChasingDots'
    | 'ThreeBounce'
    | 'Circle'
    | '9CubeGrid'
    | 'WordPress'
    | 'FadingCircle'
    | 'FadingCircleAlt'
    | 'Arc'
    | 'ArcAlt'
    | 'Plane';

  export type SpinnerProps = {
    isVisible: boolean;
    color?: string;
    size?: number;
    type?: SpinnerType;
  };

  const Spinner: React.ComponentType<SpinnerProps>;
  export default Spinner;
}

While waiting for typescript support, you can do the following:

  1. At your root, make a .d.ts file. You can name it anything you want.
  2. Copy and paste the snippet above.
steffenagger commented 5 years ago

@vTrip It looks like isVisible is also optional - see: https://github.com/maxs15/react-native-spinkit/blob/5c08bdb546cc6d54769b5f19e9a129f857c75be6/index.js#L41

But thanks! Just what I needed.