mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-07 09:49:07 +00:00
Merge pull request #17296 from buptyyf/master
add react-list type define
This commit is contained in:
43
types/react-list/index.d.ts
vendored
Normal file
43
types/react-list/index.d.ts
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Type definitions for react-list 0.8
|
||||
// Project: https://github.com/orgsync/react-list
|
||||
// Definitions by: Yifei Yan <https://github.com/buptyyf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import {
|
||||
Component,
|
||||
Props
|
||||
} from "react";
|
||||
export as namespace ReactList;
|
||||
|
||||
/*~ If this module has methods, declare them as functions like so.
|
||||
*/
|
||||
export function scrollTo(index: number): void;
|
||||
export function scrollAround(index: number): void;
|
||||
export function getVisibleRange(): number[];
|
||||
|
||||
/*~ You can declare types that are available via importing the module */
|
||||
export type ItemRenderer = (index: number, key: number | string) => JSX.Element;
|
||||
export type ItemsRenderer = (items: JSX.Element[], ref: string) => JSX.Element;
|
||||
export type ItemSizeEstimator = (index: number, cache: {}) => number;
|
||||
export type ItemSizeGetter = (index: number) => number;
|
||||
export type ScrollParentGetter = () => JSX.Element;
|
||||
|
||||
export interface ReactListProps extends Props<ReactList> {
|
||||
axis?: 'x' | 'y';
|
||||
initialIndex?: number;
|
||||
itemRenderer?: ItemRenderer;
|
||||
itemSizeEstimator?: ItemSizeEstimator;
|
||||
itemSizeGetter?: ItemSizeGetter;
|
||||
itemsRenderer?: ItemsRenderer;
|
||||
length?: number;
|
||||
minSize?: number;
|
||||
pageSize?: number;
|
||||
scrollParentGetter?: ScrollParentGetter;
|
||||
threshold?: number;
|
||||
type?: string;
|
||||
useStaticSize?: boolean;
|
||||
useTranslate3d?: boolean;
|
||||
}
|
||||
|
||||
export default class ReactList extends Component<ReactListProps, {}> {}
|
||||
14
types/react-list/react-list-tests.tsx
Normal file
14
types/react-list/react-list-tests.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from "react";
|
||||
// import * as ReactDOM from "react-dom";
|
||||
import ReactList from "react-list";
|
||||
|
||||
const renderItem = (index: number, key: number) =>
|
||||
<div key={key} className={'item' + (index % 2 ? '' : ' even')}>
|
||||
{index}
|
||||
</div>;
|
||||
|
||||
<ReactList
|
||||
itemRenderer={renderItem}
|
||||
type="uniform"
|
||||
length={1000}
|
||||
/>;
|
||||
24
types/react-list/tsconfig.json
Normal file
24
types/react-list/tsconfig.json
Normal 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-list-tests.tsx"
|
||||
]
|
||||
}
|
||||
1
types/react-list/tslint.json
Normal file
1
types/react-list/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user