From b47a6d3d0723fe1d425e7fa144ab47b680a2b70e Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 17 Jan 2018 19:11:10 +0100 Subject: [PATCH] Added types for react-click-outside (#22985) --- types/react-click-outside/index.d.ts | 11 +++++++ .../react-click-outside-tests.tsx | 30 +++++++++++++++++++ types/react-click-outside/tsconfig.json | 25 ++++++++++++++++ types/react-click-outside/tslint.json | 1 + 4 files changed, 67 insertions(+) create mode 100644 types/react-click-outside/index.d.ts create mode 100644 types/react-click-outside/react-click-outside-tests.tsx create mode 100644 types/react-click-outside/tsconfig.json create mode 100644 types/react-click-outside/tslint.json diff --git a/types/react-click-outside/index.d.ts b/types/react-click-outside/index.d.ts new file mode 100644 index 0000000000..4f5f7e96cb --- /dev/null +++ b/types/react-click-outside/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for react-click-outside 3.0 +// Project: https://github.com/kentor/react-click-outside +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 +import * as React from "react"; + +declare function enhanceWithClickOutside

(wrappedComponent: React.ComponentClass

): React.ComponentClass

; + +declare namespace enhanceWithClickOutside { } +export = enhanceWithClickOutside; diff --git a/types/react-click-outside/react-click-outside-tests.tsx b/types/react-click-outside/react-click-outside-tests.tsx new file mode 100644 index 0000000000..6f215e39a8 --- /dev/null +++ b/types/react-click-outside/react-click-outside-tests.tsx @@ -0,0 +1,30 @@ +import * as React from 'react'; +import { render } from 'react-dom'; +import * as enhanceWithClickOutside from 'react-click-outside'; + +interface Props { + text: string; +} + +interface State { + isOpened: boolean; +} + +class StatefulComponent extends React.Component { + constructor(props: Props) { + super(props); + this.state = { isOpened: true }; + } + + handleClickOutside() { + this.setState({ isOpened: false }); + } + + render() { + return

{this.props.text}
; + } +} + +const ClickOutsideStatefulComponent = enhanceWithClickOutside(StatefulComponent); + +render(, document.getElementById('test')); diff --git a/types/react-click-outside/tsconfig.json b/types/react-click-outside/tsconfig.json new file mode 100644 index 0000000000..57ca39a8f0 --- /dev/null +++ b/types/react-click-outside/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-click-outside-tests.tsx" + ] +} diff --git a/types/react-click-outside/tslint.json b/types/react-click-outside/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-click-outside/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }