From 7d096fb1bdbd7210ba44eb4032d1953d2a4bba9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Thu, 18 Nov 2021 15:17:24 +0100 Subject: [PATCH] fix: add typescript typings (#21) This adds support for typescript --- index.d.ts | 18 ++++++++++++++++++ package.json | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..d739429 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,18 @@ +export interface UseKeyboardOptions { + /** + * @default false + */ + useWillShow?: boolean + /** + * @default false + */ + useWillHide?: boolean +} + +/** + * Hook that listens to keyboard events and tell whether the keyboard is currently + * visible or not. + * Returns [isVisible, a dismiss function] + */ +declare const useKeyboard: (options?: UseKeyboardOptions) => [boolean, () => void]; +export default useKeyboard; diff --git a/package.json b/package.json index f141eec..7759a5d 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "dist/react-native-hooks-keyboard.cjs.js", "jsnext:main": "dist/react-native-hooks-keyboard.esm.js", "module": "dist/react-native-hooks-keyboard.esm.js", + "types": "index.d.ts", "scripts": { "prebuild": "rimraf dist", "prepublishOnly": "run-s build", @@ -19,7 +20,8 @@ "yalc": "npm run build && yalc push" }, "files": [ - "dist" + "dist", + "index.d.ts" ], "keywords": [ "react-native",