react-native-multiple-image-picker icon indicating copy to clipboard operation
react-native-multiple-image-picker copied to clipboard

Type mismatch openPicker using singleSelectedMode

Open mitsuharu opened this issue 2 years ago • 2 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @baronha/[email protected] for the project I'm working on.

I notice that openPicker type is not correct in TypeScript. I want to use singleSelectedMode, but TypeScript suggests MultiPicker.

Here is the diff that solved my problem:

diff --git a/node_modules/@baronha/react-native-multiple-image-picker/src/index.d.ts b/node_modules/@baronha/react-native-multiple-image-picker/src/index.d.ts
index 690360c..f8ec0d3 100644
--- a/node_modules/@baronha/react-native-multiple-image-picker/src/index.d.ts
+++ b/node_modules/@baronha/react-native-multiple-image-picker/src/index.d.ts
@@ -93,16 +93,15 @@ interface MediaTypeResults {
   [MediaType.ALL]: ImageResults | VideoResults;
 }
 
-export type IOpenPicker = <T extends MediaType = MediaType.ALL>(
-  options: MultiPickerOptions & MediaTypeOptions[T] & Options<T>
-) => Promise<MediaTypeResults[T][]>;
-
 type MultipleImagePickerType = {
-  openPicker: IOpenPicker;
+  openPicker<T extends MediaType = MediaType.ALL>(
+    options: MultiPickerOptions & MediaTypeOptions[T] & Options<T>
+  ): Promise<MediaTypeResults[T][]>;
+  openPicker<T extends MediaType = MediaType.ALL>(
+    options: SinglePickerOptions & MediaTypeOptions[T] & Options<T>
+  ): Promise<MediaTypeResults[T]>;
 };
 
 const { MultipleImagePicker } = NativeModules;
 
-export const { openPicker } = MultipleImagePicker as MultipleImagePickerType;
-
 export default MultipleImagePicker as MultipleImagePickerType;

This issue body was partially generated by patch-package.

mitsuharu avatar Nov 24 '23 13:11 mitsuharu

It would be great if I could get PR from you

baronha avatar Nov 26 '23 09:11 baronha

Thanks! I make PR #132

mitsuharu avatar Dec 02 '23 09:12 mitsuharu