From c77d6dad5e37018c8ec14f99b3e2188fd1de9990 Mon Sep 17 00:00:00 2001 From: Jonathan Ly Date: Mon, 18 Feb 2019 13:25:13 +1100 Subject: [PATCH] [react-scroll-into-view-if-needed] add types --- .../index.d.ts | 21 ++++++++ ...react-scroll-into-view-if-needed-tests.tsx | 52 +++++++++++++++++++ .../tsconfig.json | 17 ++++++ .../tslint.json | 1 + 4 files changed, 91 insertions(+) create mode 100644 types/react-scroll-into-view-if-needed/index.d.ts create mode 100644 types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx create mode 100644 types/react-scroll-into-view-if-needed/tsconfig.json create mode 100644 types/react-scroll-into-view-if-needed/tslint.json diff --git a/types/react-scroll-into-view-if-needed/index.d.ts b/types/react-scroll-into-view-if-needed/index.d.ts new file mode 100644 index 0000000000..2522833fbd --- /dev/null +++ b/types/react-scroll-into-view-if-needed/index.d.ts @@ -0,0 +1,21 @@ +// Type definitions for react-scroll-into-view-if-needed 2.1 +// Project: https://github.com/icd2k3/react-scroll-into-view-if-needed#readme +// Definitions by: Angus Fretwell +// Allan Pope +// Jonathan Ly +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.9 + +import * as React from 'react'; +import * as ScrollIntoViewIfNeeded from 'scroll-into-view-if-needed'; + +export interface ReactScrollIntoViewIfNeededProps + extends React.HTMLProps { + options?: ScrollIntoViewIfNeeded.Options; + active?: boolean; + elementType?: keyof JSX.IntrinsicElements; +} + +export default class ReactScrollIntoViewIfNeeded extends React.Component< + ReactScrollIntoViewIfNeededProps +> {} diff --git a/types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx b/types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx new file mode 100644 index 0000000000..d9845582e7 --- /dev/null +++ b/types/react-scroll-into-view-if-needed/react-scroll-into-view-if-needed-tests.tsx @@ -0,0 +1,52 @@ +import * as React from 'react'; +import ReactScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed'; + +const validOptions = { + block: 'start', + scrollMode: 'if-needed', + skipOverflowHiddenElements: true +}; + +const invalidOptions = { + invalidOption: 'foobar' +}; + +() => ( + + Children + +); + +() => ( + + Children + +); + +() => ( + + Children + +); + +() => ( + + Children + +); diff --git a/types/react-scroll-into-view-if-needed/tsconfig.json b/types/react-scroll-into-view-if-needed/tsconfig.json new file mode 100644 index 0000000000..cfa539dc78 --- /dev/null +++ b/types/react-scroll-into-view-if-needed/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-scroll-into-view-if-needed-tests.tsx"] +} diff --git a/types/react-scroll-into-view-if-needed/tslint.json b/types/react-scroll-into-view-if-needed/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-scroll-into-view-if-needed/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }