Add type definitions for react-lazyload package. (#16807)

* Add type definitions for `react-lazyload` package.

* fix lint error.

* fix TypeScript Version
This commit is contained in:
makoto abe 2017-06-01 15:39:55 +09:00 committed by Mohamed Hegazy
parent a6d85e88c1
commit d82cb80219
4 changed files with 83 additions and 0 deletions

26
types/react-lazyload/index.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
// Type definitions for react-lazyload ver 2.2
// Project: https://github.com/jasonslyvia/react-lazyload
// Definitions by: m0a <https://github.com/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<LazyLoadProps, {}> {
constructor(props: LazyLoad);
}
export function lazyload(option: {}): LazyLoad;

View File

@ -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 (
<div>
{this.state.arr.map((el, index) => {
return (
<LazyLoad once={true} key={index} height={200} offset={50}>
<p id={`${index}`} >
count={index + 1}
</p>
</LazyLoad>
);
})}
</div>
);
}
}

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }