react-native-swipe-item
react-native-swipe-item copied to clipboard
SwipeProvider unusable with Typescript
SwipeProvider breaks on type checking, all the component becomes red and types are not compatible. Error message is below ( copied from VS code ). Temporary fix is putting /* @ts-ignore */ above the component
No overload matches this call. Overload 1 of 2, '(props: SwipeProviderProps | Readonly<SwipeProviderProps>): SwipeProvider', gave the following error. Type '{ children: Element[]; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<SwipeProvider> & Readonly<SwipeProviderProps>'. Overload 2 of 2, '(props: SwipeProviderProps, context: any): SwipeProvider', gave the following error. Type '{ children: Element[]; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<SwipeProvider> & Readonly<SwipeProviderProps>'.ts(2769)
it same my error I have to fix ./node_modules/react-native-swipe-item/index.d.tsx to add some code
declare module 'react-native-swipe-item' { .. interface SwipeProviderProps { /** * Swipe items mode, default is single */
mode?: 'single' | 'multiple';
/**
* The trigger for automatically closed swipe item , default is onItemMoved
* `onItemMoved` - when the swipe item is moved, the opened one will be closed.
* `onButtonShowed` - when the swipe item button is showing, the opened one will be closed.
*/
closeTrigger?: 'onItemMoved' | 'onButtonShowed';
children: Element; //add code fix error
}
}