Skip to content

Commit 3e3521e

Browse files
committed
fix isCancel type to boolean and add new error type test
1 parent 282f289 commit 3e3521e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

__tests__/typescript/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,13 @@ DocumentPicker.pickMultiple({
6363
DocumentPicker.pickMultiple({
6464
type: [DocumentPicker.types.video,DocumentPicker.types.pdf, 'public.audio']
6565
})
66+
67+
try {
68+
throw new Error('test')
69+
} catch (e) {
70+
if(DocumentPicker.isCancel(e)){
71+
72+
} else {
73+
74+
}
75+
}

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ declare module 'react-native-document-picker' {
4949
static pickMultiple<OS extends keyof PlatformTypes = Platform>(
5050
options: DocumentPickerOptions<OS>
5151
): Promise<DocumentPickerResponse>;
52-
static isCancel(err: any): void;
52+
static isCancel<IError extends {code?: string}>(err?: IError): boolean;
5353
}
5454
}

0 commit comments

Comments
 (0)