diff --git a/types/react-native-touch-id/index.d.ts b/types/react-native-touch-id/index.d.ts new file mode 100644 index 0000000000..04f7fbbfde --- /dev/null +++ b/types/react-native-touch-id/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for react-native-touch-id 3.0.0 +// Project: https://github.com/naoufal/react-native-touch-id +// Definitions by: huhuanming +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'react-native-touch-id' { + + class TouchIDError { + name: 'LAErrorAuthenticationFailed' | 'LAErrorUserCancel' | 'LAErrorUserFallback' | 'LAErrorSystemCancel' + | 'LAErrorPasscodeNotSet' | 'LAErrorTouchIDNotAvailable' | 'LAErrorTouchIDNotEnrolled' + | 'LAErrorTouchIDNotEnrolled' | 'RCTTouchIDUnknownError' | 'RCTTouchIDNotSupported'; + message: string; + details: any; + } + + export const isSupported: () => Promise; + export const authenticate: (reason: string) => Promise; +} diff --git a/types/react-native-touch-id/react-native-touch-id-tests.ts b/types/react-native-touch-id/react-native-touch-id-tests.ts new file mode 100644 index 0000000000..009f1c347f --- /dev/null +++ b/types/react-native-touch-id/react-native-touch-id-tests.ts @@ -0,0 +1,5 @@ +import { isSupported, authenticate } from 'react-native-touch-id'; + +isSupported().then(() => {}).catch(() => {}); + +authenticate('reason').then(() => {}).catch(() => {}); diff --git a/types/react-native-touch-id/tsconfig.json b/types/react-native-touch-id/tsconfig.json new file mode 100644 index 0000000000..0a1cd74c96 --- /dev/null +++ b/types/react-native-touch-id/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-native-touch-id-tests.ts" + ] +}