From d82cb802198eefe80ca4f64330a726909dfc2196 Mon Sep 17 00:00:00 2001 From: makoto abe Date: Thu, 1 Jun 2017 15:39:55 +0900 Subject: [PATCH] Add type definitions for `react-lazyload` package. (#16807) * Add type definitions for `react-lazyload` package. * fix lint error. * fix TypeScript Version --- types/react-lazyload/index.d.ts | 26 +++++++++++++++ types/react-lazyload/react-lazyload-tests.tsx | 32 +++++++++++++++++++ types/react-lazyload/tsconfig.json | 24 ++++++++++++++ types/react-lazyload/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 types/react-lazyload/index.d.ts create mode 100644 types/react-lazyload/react-lazyload-tests.tsx create mode 100644 types/react-lazyload/tsconfig.json create mode 100644 types/react-lazyload/tslint.json diff --git a/types/react-lazyload/index.d.ts b/types/react-lazyload/index.d.ts new file mode 100644 index 0000000000..fae8d78a83 --- /dev/null +++ b/types/react-lazyload/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for react-lazyload ver 2.2 +// Project: https://github.com/jasonslyvia/react-lazyload +// Definitions by: m0a +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +import {Component} from 'react'; + +export interface LazyLoadProps { + once?: boolean; + height?: number | string; + offset?: number | string; + overflow?: boolean; + scroll?: boolean; + children?: JSX.Element; + throttle?: number | boolean; + debounce?: number | boolean; + placeholder?: Node; + unmountIfInvisible?: boolean; +} + +export default class LazyLoad extends Component { + constructor(props: LazyLoad); +} + +export function lazyload(option: {}): LazyLoad; diff --git a/types/react-lazyload/react-lazyload-tests.tsx b/types/react-lazyload/react-lazyload-tests.tsx new file mode 100644 index 0000000000..37b928a99c --- /dev/null +++ b/types/react-lazyload/react-lazyload-tests.tsx @@ -0,0 +1,32 @@ +import * as React from "react"; +import LazyLoad from "react-lazyload"; + +interface State { + arr: string[]; +} + +class Normal extends React.Component<{}, State> { + constructor() { + super(); + let arr: string[] = []; + for (let i = 0; i < 200; i++) { + arr.push(`${i}`); + } + this.state = { arr }; + } + render() { + return ( +
+ {this.state.arr.map((el, index) => { + return ( + +

+ count={index + 1} +

+
+ ); + })} +
+ ); + } +} diff --git a/types/react-lazyload/tsconfig.json b/types/react-lazyload/tsconfig.json new file mode 100644 index 0000000000..d77160e99c --- /dev/null +++ b/types/react-lazyload/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-lazyload-tests.tsx" + ] +} diff --git a/types/react-lazyload/tslint.json b/types/react-lazyload/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-lazyload/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }