From 23d825ca66a225d937884f8e59547ec21de8f002 Mon Sep 17 00:00:00 2001 From: york yao Date: Thu, 28 Dec 2017 18:26:12 +0800 Subject: [PATCH] add types of react-native-document-picker --- types/react-native-document-picker/index.d.ts | 28 +++++++++++++++++++ .../react-native-document-picker-tests.tsx | 7 +++++ .../tsconfig.json | 25 +++++++++++++++++ .../react-native-document-picker/tslint.json | 1 + 4 files changed, 61 insertions(+) create mode 100644 types/react-native-document-picker/index.d.ts create mode 100644 types/react-native-document-picker/react-native-document-picker-tests.tsx create mode 100644 types/react-native-document-picker/tsconfig.json create mode 100644 types/react-native-document-picker/tslint.json diff --git a/types/react-native-document-picker/index.d.ts b/types/react-native-document-picker/index.d.ts new file mode 100644 index 0000000000..986da6e611 --- /dev/null +++ b/types/react-native-document-picker/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for react-native-document-picker 2.0 +// Project: https://github.com/Elyx0/react-native-document-picker +// Definitions by: Jacob Baskin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export const DocumentPicker: { + show(options: Options, callback: (error: Error, result: Result) => void): void; +}; + +export const DocumentPickerUtil: { + allFiles(): string; + pdf(): string; + audio(): string; + plainText(): string; +}; + +export interface Options { + top?: number; + left?: number; + filetype: string[]; +} + +export interface Result { + uri: string; + type: string; + fileName: string; + fileSize: number; +} diff --git a/types/react-native-document-picker/react-native-document-picker-tests.tsx b/types/react-native-document-picker/react-native-document-picker-tests.tsx new file mode 100644 index 0000000000..a293a20c37 --- /dev/null +++ b/types/react-native-document-picker/react-native-document-picker-tests.tsx @@ -0,0 +1,7 @@ +import { DocumentPicker, DocumentPickerUtil } from "react-native-document-picker"; + +DocumentPicker.show({ + filetype: [DocumentPickerUtil.allFiles()], +}, (error, res) => { + // do nothing +}); diff --git a/types/react-native-document-picker/tsconfig.json b/types/react-native-document-picker/tsconfig.json new file mode 100644 index 0000000000..25f0fcb7b7 --- /dev/null +++ b/types/react-native-document-picker/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-native-document-picker-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/react-native-document-picker/tslint.json b/types/react-native-document-picker/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-document-picker/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }