enable check type file at vscode and recover latest type

This commit is contained in:
tkow 2019-07-07 23:57:38 +09:00
parent 850f8baafc
commit 3dce452105
3 changed files with 59 additions and 8 deletions

View 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
View File

@ -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
View File

@ -0,0 +1,7 @@
{
"compilerOptions": {
"baseUrl": "./__tests__/typescript" ,
"types": ["./","./node_modules"]
},
"include": ["./"]
}