enable check type file at vscode and recover latest type
This commit is contained in:
parent
850f8baafc
commit
3dce452105
11
__tests__/typescript/index.test.ts
Normal file
11
__tests__/typescript/index.test.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { DocumentPicker} from "react-native-document-picker";
|
||||
|
||||
DocumentPicker.types.allFiles
|
||||
DocumentPicker.types.audio
|
||||
DocumentPicker.types.images
|
||||
DocumentPicker.types.plainText
|
||||
DocumentPicker.types.video
|
||||
|
||||
DocumentPicker.pick({
|
||||
type: [DocumentPicker.types.allFiles]
|
||||
})
|
||||
49
index.d.ts
vendored
49
index.d.ts
vendored
@ -1,7 +1,38 @@
|
||||
declare module 'react-native-document-picker' {
|
||||
interface DocumentPickerOptions {
|
||||
filetype: Array<string>;
|
||||
multiple?: Boolean;
|
||||
type Types = {
|
||||
mimeTypes: {
|
||||
allFiles: '*/*',
|
||||
audio: 'audio/*',
|
||||
images: 'image/*',
|
||||
plainText: 'text/plain',
|
||||
pdf: 'application/pdf',
|
||||
video: 'video/*',
|
||||
},
|
||||
utis: {
|
||||
allFiles: 'public.content',
|
||||
audio: 'public.audio',
|
||||
images: 'public.image',
|
||||
plainText: 'public.plain-text',
|
||||
pdf: 'com.adobe.pdf',
|
||||
video: 'public.movie',
|
||||
},
|
||||
extensions: {
|
||||
allFiles: '*',
|
||||
audio:
|
||||
'.3g2 .3gp .aac .adt .adts .aif .aifc .aiff .asf .au .m3u .m4a .m4b .mid .midi .mp2 .mp3 .mp4 .rmi .snd .wav .wax .wma',
|
||||
images: '.jpeg .jpg .png',
|
||||
plainText: '.txt',
|
||||
pdf: '.pdf',
|
||||
video: '.mp4',
|
||||
},
|
||||
};
|
||||
type PlatformTypes = {
|
||||
android: Types['mimeTypes']
|
||||
ios: Types['utis']
|
||||
windows: Types['extensions']
|
||||
};
|
||||
interface DocumentPickerOptions<OS extends keyof PlatformTypes> {
|
||||
type: Array<PlatformTypes[OS][keyof PlatformTypes[OS]]>
|
||||
}
|
||||
interface DocumentPickerResponse {
|
||||
uri: string;
|
||||
@ -9,12 +40,14 @@ declare module 'react-native-document-picker' {
|
||||
fileName: string;
|
||||
fileSize: string;
|
||||
}
|
||||
export class DocumentPicker {
|
||||
static pick(
|
||||
options: { multiple: false } & DocumentPickerOptions
|
||||
type Platform = 'ios' | 'android' | 'windows'
|
||||
export class DocumentPicker<OS extends keyof PlatformTypes = Platform> {
|
||||
static types: PlatformTypes['ios'] | PlatformTypes['android'] | PlatformTypes['windows']
|
||||
static pick<OS extends keyof PlatformTypes = Platform>(
|
||||
options: DocumentPickerOptions<OS>
|
||||
): Promise<DocumentPickerResponse>;
|
||||
static pickMultiple(
|
||||
options: { multiple: true } & DocumentPickerOptions
|
||||
static pickMultiple<OS extends keyof PlatformTypes = Platform>(
|
||||
options: DocumentPickerOptions<OS>
|
||||
): Promise<DocumentPickerResponse>;
|
||||
static isCancel(err: any): void;
|
||||
}
|
||||
|
||||
7
tsconfig.json
Normal file
7
tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./__tests__/typescript" ,
|
||||
"types": ["./","./node_modules"]
|
||||
},
|
||||
"include": ["./"]
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user