react-native-swipe-item icon indicating copy to clipboard operation
react-native-swipe-item copied to clipboard

SwipeProvider unusable with Typescript

Open kris1803 opened this issue 2 years ago • 1 comments

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)

kris1803 avatar Oct 21 '22 15:10 kris1803

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
}

}

faisolp avatar Feb 28 '23 05:02 faisolp