Closed 28harishkumar closed 4 years ago
I just noticed this as well after bumping to new v6.0.0
You might try this patch in patch-package format, I'll open a PR - I'm testing it now locally
After installing patch-package paste this into the file patches/react-native-contacts+6.0.0.patch
and re-run your package install (or run npx patch-package
I guess) to install it and test
diff --git a/node_modules/react-native-contacts/index.d.ts b/node_modules/react-native-contacts/index.d.ts
index 3b82c59..dd0a81f 100644
--- a/node_modules/react-native-contacts/index.d.ts
+++ b/node_modules/react-native-contacts/index.d.ts
@@ -1,19 +1,19 @@
-export function getAll(callback: (error: any, contacts: Contact[]) => void): void;
-export function getAllWithoutPhotos(callback: (error: any, contacts: Contact[]) => void): void;
-export function getContactById(contactId: string, callback: (error: any, contact: Contact) => void): void;
-export function getCount(callback: (count: number) => void): void;
-export function getPhotoForId(contactId: string, callback: (error: any, photoUri: string) => void): void;
-export function addContact(contact: Contact, callback: (error?: any) => void): void;
-export function openContactForm(contact: Partial<Contact>, callback: (error: any, contact: Contact) => void): void;
-export function openExistingContact(contact: Contact, callback: (error: any, contact: Contact) => void): void;
-export function editExistingContact(contact: Contact, callback: (error: any, contact: Contact) => void): void;
-export function updateContact(contact: Contact, callback: (error?: any) => void): void;
-export function deleteContact(contact: Contact, callback: (error?: any) => void): void;
-export function getContactsMatchingString(str: string, callback: (error: any, contacts: Contact[]) => void): void;
-export function getContactsByPhoneNumber(phoneNumber: string, callback: (error: any, contacts: Contact[]) => void): void;
-export function checkPermission(callback: (error: any, result: 'authorized' | 'denied' | 'undefined') => void): void;
-export function requestPermission(callback: (error: any, result: 'authorized' | 'denied' | 'undefined') => void): void;
-export function writePhotoToPath(contactId: string, file: string, callback: (error: any, result: boolean) => void): void;
+export function getAll(): Promise<Contact[]>;
+export function getAllWithoutPhotos(): Promise<Contact[]>;
+export function getContactById(contactId: string): Promise<Contact>;
+export function getCount(): Promise<number>;
+export function getPhotoForId(contactId: string): Promise<string>;
+export function addContact(contact: Contact): Promise<void>;
+export function openContactForm(contact: Partial<Contact>): Promise<Contact>;
+export function openExistingContact(contact: Contact): Promise<Contact>;
+export function editExistingContact(contact: Contact): Promise<Contact>;
+export function updateContact(contact: Contact): Promise<void>;
+export function deleteContact(contact: Contact): Promise<void>;
+export function getContactsMatchingString(str: string): Promise<Contact[]>;
+export function getContactsByPhoneNumber(phoneNumber: string): Promise<Contact[]>;
+export function checkPermission(): Promise<'authorized' | 'denied' | 'undefined'>;
+export function requestPermission(): Promise<'authorized' | 'denied' | 'undefined'>;
+export function writePhotoToPath(contactId: string, file: string): Promise<boolean>;
export function iosEnableNotesUsage(enabled: boolean): void;
export interface EmailAddress {
According to documents
getAll
is returning a promiseBut index.d.ts is expecting a callback
export function getAll(callback: (error: any, contacts: Contact[]) => void): void;
I want to use this package for my project in typescript and can open a PR (if I am allowed).