From 07fae015dd930bcdc8587352bb0c2b7d813ccdc0 Mon Sep 17 00:00:00 2001 From: Bryan Deloeste Date: Thu, 11 Apr 2019 13:24:06 -0700 Subject: [PATCH] [react-click-outside-hook] add type def for useClickOutside function --- types/react-click-outside-hook/index.d.ts | 8 ++++++++ .../react-click-outside-hook-tests.tsx | 11 +++++++++++ types/react-click-outside-hook/tsconfig.json | 16 ++++++++++++++++ types/react-click-outside-hook/tslint.json | 1 + 4 files changed, 36 insertions(+) create mode 100644 types/react-click-outside-hook/index.d.ts create mode 100644 types/react-click-outside-hook/react-click-outside-hook-tests.tsx create mode 100644 types/react-click-outside-hook/tsconfig.json create mode 100644 types/react-click-outside-hook/tslint.json diff --git a/types/react-click-outside-hook/index.d.ts b/types/react-click-outside-hook/index.d.ts new file mode 100644 index 0000000000..3e4d845753 --- /dev/null +++ b/types/react-click-outside-hook/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for react-click-outside-hook 1.0 +// Project: https://github.com/bdeloeste/react-click-outside-hook#readme +// Definitions by: Bryan Deloeste +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { MutableRefObject } from "react"; + +export function useClickOutside(): [MutableRefObject, boolean]; diff --git a/types/react-click-outside-hook/react-click-outside-hook-tests.tsx b/types/react-click-outside-hook/react-click-outside-hook-tests.tsx new file mode 100644 index 0000000000..b5ce2ad7a6 --- /dev/null +++ b/types/react-click-outside-hook/react-click-outside-hook-tests.tsx @@ -0,0 +1,11 @@ +import * as React from "react"; +import { render } from "react-dom"; + +import { useClickOutside } from "react-click-outside-hook"; + +function Component() { + const [ref, hasClickedOutside] = useClickOutside(); + return
{hasClickedOutside.toString()}
; +} + +render(, document.getElementById("test")); diff --git a/types/react-click-outside-hook/tsconfig.json b/types/react-click-outside-hook/tsconfig.json new file mode 100644 index 0000000000..4d9fefbdc4 --- /dev/null +++ b/types/react-click-outside-hook/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-click-outside-hook-tests.tsx"] +} diff --git a/types/react-click-outside-hook/tslint.json b/types/react-click-outside-hook/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-click-outside-hook/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }