From 4b37cc7d6c5f03b6f963ff4be501be3fb8daa2a0 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 11 Jun 2019 18:12:10 +0300 Subject: [PATCH] Upgrade flow and fix issues --- package.json | 21 ++++++++++++--------- src/FixedSizeList.js | 4 ++-- src/createGridComponent.js | 20 ++++++++++++++++++-- src/createListComponent.js | 20 ++++++++++++++++++-- yarn.lock | 7 ++++--- 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 82ec380..f7356db 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,8 @@ { "name": "react-window", "version": "1.8.2", - "description": - "React components for efficiently rendering large, scrollable lists and tabular data", - "author": - "Brian Vaughn (https://github.com/bvaughn/)", + "description": "React components for efficiently rendering large, scrollable lists and tabular data", + "author": "Brian Vaughn (https://github.com/bvaughn/)", "contributors": [ "Brian Vaughn (https://github.com/bvaughn/)" ], @@ -36,7 +34,10 @@ ], "main": "dist/index.cjs.js", "module": "dist/index.esm.js", - "files": ["dist", "src/*.js"], + "files": [ + "dist", + "src/*.js" + ], "scripts": { "flow": "flow check --max-warnings=0 src && flow check website", "precommit": "lint-staged", @@ -45,8 +46,7 @@ "lint": "eslint '**/*.js'", "test": "cross-env CI=1 react-scripts test --env=jsdom", "test:watch": "react-scripts test --env=jsdom", - "build:flow": - "cp flow-template dist/index.cjs.js.flow && cp flow-template dist/index.esm.js.flow", + "build:flow": "cp flow-template dist/index.cjs.js.flow && cp flow-template dist/index.esm.js.flow", "build:source": "rollup -c", "build": "del dist && mkdir dist && yarn build:flow && yarn build:source", "start": "rollup -c -w", @@ -56,7 +56,10 @@ "website:run": "cd website && yarn start" }, "lint-staged": { - "{website,src}/**/*.{js,json,css}": ["prettier --write", "git add"], + "{website,src}/**/*.{js,json,css}": [ + "prettier --write", + "git add" + ], "**/*.js": "eslint --max-warnings 0" }, "dependencies": { @@ -91,7 +94,7 @@ "eslint-plugin-promise": "^3.7.0", "eslint-plugin-react": "^7.7.0", "eslint-plugin-standard": "^3.0.1", - "flow-bin": "^0.80.0", + "flow-bin": "^0.101.0", "gh-pages": "^1.1.0", "lint-staged": "^7.0.5", "prettier": "^1.12.1", diff --git a/src/FixedSizeList.js b/src/FixedSizeList.js index 991f900..4da6211 100644 --- a/src/FixedSizeList.js +++ b/src/FixedSizeList.js @@ -5,10 +5,10 @@ import createListComponent from './createListComponent'; import type { Props, ScrollToAlign } from './createListComponent'; const FixedSizeList = createListComponent({ - getItemOffset: ({ itemSize, size }: Props, index: number): number => + getItemOffset: ({ itemSize }: Props, index: number): number => index * ((itemSize: any): number), - getItemSize: ({ itemSize, size }: Props, index: number): number => + getItemSize: ({ itemSize }: Props, index: number): number => ((itemSize: any): number), getEstimatedTotalSize: ({ itemCount, itemSize }: Props) => diff --git a/src/createGridComponent.js b/src/createGridComponent.js index 0900fb2..38aea63 100644 --- a/src/createGridComponent.js +++ b/src/createGridComponent.js @@ -46,6 +46,22 @@ type OnScrollCallback = ({ type ScrollEvent = SyntheticEvent; type ItemStyleCache = { [key: string]: Object }; +type OuterProps = {| + children: React$Node, + className: string | void, + onScroll: ScrollEvent => void, + style: { + [string]: mixed, + }, +|}; + +type InnerProps = {| + children: React$Node, + style: { + [string]: mixed, + }, +|}; + export type Props = {| children: RenderComponent, className?: string, @@ -56,7 +72,7 @@ export type Props = {| initialScrollLeft?: number, initialScrollTop?: number, innerRef?: any, - innerElementType?: React$ElementType, + innerElementType?: string | React$AbstractComponent, innerTagName?: string, // deprecated itemData: T, itemKey?: (params: {| @@ -67,7 +83,7 @@ export type Props = {| onItemsRendered?: OnItemsRenderedCallback, onScroll?: OnScrollCallback, outerRef?: any, - outerElementType?: React$ElementType, + outerElementType?: string | React$AbstractComponent, outerTagName?: string, // deprecated overscanColumnCount?: number, overscanColumnsCount?: number, // deprecated diff --git a/src/createListComponent.js b/src/createListComponent.js index 00ca782..5326d3b 100644 --- a/src/createListComponent.js +++ b/src/createListComponent.js @@ -39,6 +39,22 @@ type onScrollCallback = ({ type ScrollEvent = SyntheticEvent; type ItemStyleCache = { [index: number]: Object }; +type OuterProps = {| + children: React$Node, + className: string | void, + onScroll: ScrollEvent => void, + style: { + [string]: mixed, + }, +|}; + +type InnerProps = {| + children: React$Node, + style: { + [string]: mixed, + }, +|}; + export type Props = {| children: RenderComponent, className?: string, @@ -46,7 +62,7 @@ export type Props = {| height: number | string, initialScrollOffset?: number, innerRef?: any, - innerElementType?: React$ElementType, + innerElementType?: string | React$AbstractComponent, innerTagName?: string, // deprecated itemCount: number, itemData: T, @@ -56,7 +72,7 @@ export type Props = {| onItemsRendered?: onItemsRenderedCallback, onScroll?: onScrollCallback, outerRef?: any, - outerElementType?: React$ElementType, + outerElementType?: string | React$AbstractComponent, outerTagName?: string, // deprecated overscanCount: number, style?: Object, diff --git a/yarn.lock b/yarn.lock index 2bd7c3f..677f5ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3692,9 +3692,10 @@ flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" -flow-bin@^0.80.0: - version "0.80.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.80.0.tgz#04cc1ee626a6f50786f78170c92ebe1745235403" +flow-bin@^0.101.0: + version "0.101.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.101.0.tgz#c56fa0afb9c151eeba7954136e9066d408691063" + integrity sha512-2xriPEOSrGQklAArNw1ixoIUiLTWhIquYV26WqnxEu7IcXWgoZUcfJXufG9kIvrNbdwCNd5RBjTwbB0p6L6XaA== follow-redirects@^1.0.0: version "1.4.1"