From ba94ba69b167a950e2aeea81f1efa7d7db4a6bd9 Mon Sep 17 00:00:00 2001 From: Barry Michael Doyle Date: Fri, 27 Dec 2019 17:09:48 +0200 Subject: [PATCH] Added react-fade-in Type Definitions (#41182) * added react-fade-in type definitions * added version in * added type definitions for react-hook-mousetrap * resolved prefer-declare-function error --- types/react-fade-in/index.d.ts | 30 ++++++++++++++ types/react-fade-in/react-fade-in-tests.tsx | 40 +++++++++++++++++++ types/react-fade-in/tsconfig.json | 25 ++++++++++++ types/react-fade-in/tslint.json | 1 + types/react-hook-mousetrap/index.d.ts | 9 +++++ .../react-hook-mousetrap-tests.tsx | 8 ++++ types/react-hook-mousetrap/tsconfig.json | 25 ++++++++++++ types/react-hook-mousetrap/tslint.json | 1 + 8 files changed, 139 insertions(+) create mode 100644 types/react-fade-in/index.d.ts create mode 100644 types/react-fade-in/react-fade-in-tests.tsx create mode 100644 types/react-fade-in/tsconfig.json create mode 100644 types/react-fade-in/tslint.json create mode 100644 types/react-hook-mousetrap/index.d.ts create mode 100644 types/react-hook-mousetrap/react-hook-mousetrap-tests.tsx create mode 100644 types/react-hook-mousetrap/tsconfig.json create mode 100644 types/react-hook-mousetrap/tslint.json diff --git a/types/react-fade-in/index.d.ts b/types/react-fade-in/index.d.ts new file mode 100644 index 0000000000..6100fc8a2b --- /dev/null +++ b/types/react-fade-in/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for react-fade-in 0.1 +// Project: github.com/gkaemmer/react-fade-in +// Definitions by: Barry Michael Doyle +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + +import { ComponentClass, ReactNode } from 'react'; + +/** + * Props for a FadeIn component. + */ +export interface FadeInProps { + children?: ReactNode; + className?: string; + /** + * Default: 50. Delay between each child's animation in milliseconds. + */ + delay?: number; + /** + * Default: 400. Duration of each child's animation in milliseconds. + */ + transitionDuration?: number; +} + +/** + * Visually animates content on render with FadeIn.js + */ +declare const FadeIn: ComponentClass; + +export default FadeIn; diff --git a/types/react-fade-in/react-fade-in-tests.tsx b/types/react-fade-in/react-fade-in-tests.tsx new file mode 100644 index 0000000000..7171ffc658 --- /dev/null +++ b/types/react-fade-in/react-fade-in-tests.tsx @@ -0,0 +1,40 @@ +import * as React from 'react'; +import FadeIn from 'react-fade-in'; + +export const _ = () => ( + <> + + +
Element 1
+
Element 2
+
Element 3
+
Element 4
+
Element 5
+
Element 6
+
+ +
Element 1
+
Element 2
+
Element 3
+
Element 4
+
Element 5
+
Element 6
+
+ +
Element 1
+
Element 2
+
Element 3
+
Element 4
+
Element 5
+
Element 6
+
+ +
Element 1
+
Element 2
+
Element 3
+
Element 4
+
Element 5
+
Element 6
+
+ +); diff --git a/types/react-fade-in/tsconfig.json b/types/react-fade-in/tsconfig.json new file mode 100644 index 0000000000..895d8bca05 --- /dev/null +++ b/types/react-fade-in/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-fade-in-tests.tsx" + ] +} diff --git a/types/react-fade-in/tslint.json b/types/react-fade-in/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-fade-in/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-hook-mousetrap/index.d.ts b/types/react-hook-mousetrap/index.d.ts new file mode 100644 index 0000000000..8eb0ebe840 --- /dev/null +++ b/types/react-hook-mousetrap/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for react-hook-mousetrap 2.0 +// Project: https://github.com/olup/react-hook-mousetrap +// Definitions by: Barry Michael Doyle +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 + +declare function useMousetrap(keys: string | string[], callback: () => void): void; + +export default useMousetrap; diff --git a/types/react-hook-mousetrap/react-hook-mousetrap-tests.tsx b/types/react-hook-mousetrap/react-hook-mousetrap-tests.tsx new file mode 100644 index 0000000000..aae281fcde --- /dev/null +++ b/types/react-hook-mousetrap/react-hook-mousetrap-tests.tsx @@ -0,0 +1,8 @@ +import useMousetrap from 'react-hook-mousetrap'; + +export const _ = () => { + useMousetrap('down', () => console.log('down arrow pressed')); + useMousetrap(['left', 'right'], () => console.log('left or right arrow pressed')); + + return null; +}; diff --git a/types/react-hook-mousetrap/tsconfig.json b/types/react-hook-mousetrap/tsconfig.json new file mode 100644 index 0000000000..3092442c7a --- /dev/null +++ b/types/react-hook-mousetrap/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-hook-mousetrap-tests.tsx" + ] +} diff --git a/types/react-hook-mousetrap/tslint.json b/types/react-hook-mousetrap/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-hook-mousetrap/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }