[Improvement] Typescript support
mohannad-mamo opened this issue · 3 comments
mohannad-mamo commented
Hello,
as I am using Typescript for developing, I had to type this module so it is usable with linting.
Maybe it is helpful for others, here is the code:
`
declare module "react-native-card-flip" {
import { StyleProp, ViewStyle } from "react-native";
interface Card {
/**
* Flips the card
*/
flip: () => void;
/**
* Flips the card
* @default { direction: 'left', progress: 0.05, duration: 150 }
*/
tip: (direction: 'y'|'x', progress: number, duration: number) => void;
/**
* Jiggles the card
* @default { count: 2, duration: 200, progress: 0.05 }
*/
jiggle: (count: number, duration: number, progress: number) => void;
}
interface Props {
/**
* container style
* @default {}
*/
style?: StyleProp<ViewStyle>;
/**
* flip duration
* @default 1000
*/
duration?: number;
/**
* zoom level on flip
* @default 0.09
*/
flipZoom?: number;
/**
* the rotation axis. 'x' or 'y'
* @default 'y'
*/
flipDirection?: 'y'|'x';
/**
* @default 800
*/
perspective?: number;
ref?: (card: Card) => void;
children?: any;
/**
* function to be called when a card is fliped. it receives the card-sides index
*/
onFlip?: () => void;
/**
* function to be called when the flip-animation starts. it receives the card-sides index
*/
onFlipStart?: () => void;
/**
* function to be called when the flip-animation ends. it receives the card-sides index
*/
onFlipEnd?: () => void;
}
export default function CardFlip(props: Props): JSX.Element;
}
`
gekitz commented
Thank you!
garfieldnate commented
I'm a little confused by this. The repository already has an index.d.ts file in it. The author has not released to NPM in a long time, but I think that when they do we will have types available.
lhandel commented
This update is now updated on npm