diff --git a/types/react-window/index.d.ts b/types/react-window/index.d.ts index cd98a709e1..c74440f562 100644 --- a/types/react-window/index.d.ts +++ b/types/react-window/index.d.ts @@ -4,7 +4,15 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Component, ComponentType, CSSProperties, Ref, Key } from "react"; +import { + Component, + ComponentType, + CSSProperties, + Ref, + Key, + FunctionComponent, + ComponentClass +} from "react"; export type Direction = "vertical" | "horizontal"; export type ScrollDirection = "forward" | "backward"; @@ -25,17 +33,27 @@ export interface GridChildComponentProps { isScrolling?: boolean; } +// This is supposed to represent the type of the first parameter to +// React.createElement. +type ReactElementType = FunctionComponent | ComponentClass | string; + export interface CommonProps { /** * Optional CSS class to attach to outermost
element. */ className?: string; + /** + * Tag name passed to document.createElement to create the inner container element. This is an advanced property; in most cases, the default ("div") should be used. + */ + innerElementType?: ReactElementType; /** * Ref to attach to the inner container element. This is an advanced property. */ innerRef?: Ref; /** * Tag name passed to document.createElement to create the inner container element. This is an advanced property; in most cases, the default ("div") should be used. + * + * @deprecated since 1.4.0 */ innerTagName?: string; /** @@ -44,12 +62,18 @@ export interface CommonProps { * Item data is useful for item renderers that are class components. */ itemData?: any; + /** + * Tag name passed to document.createElement to create the outer container element. This is an advanced property; in most cases, the default ("div") should be used. + */ + outerElementType?: ReactElementType; /** * Ref to attach to the outer container element. This is an advanced property. */ outerRef?: Ref; /** * Tag name passed to document.createElement to create the outer container element. This is an advanced property; in most cases, the default ("div") should be used. + * + * @deprecated since 1.4.0 */ outerTagName?: string; /** diff --git a/types/react-window/react-window-tests.tsx b/types/react-window/react-window-tests.tsx index 8cad93227f..d41b95474d 100644 --- a/types/react-window/react-window-tests.tsx +++ b/types/react-window/react-window-tests.tsx @@ -66,7 +66,7 @@ const FixedSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({ direction={testBool ? "vertical" : "horizontal"} initialScrollOffset={0} innerRef={anyRef} - innerTagName="div" + innerElementType="div" itemData={{ foo: "bar" }} itemKey={index => "foo" + index.toString()} onItemsRendered={({ @@ -81,7 +81,7 @@ const FixedSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({ visibleStopIndex } useIsScrolling={true} - outerTagName="div" + outerElementType="div" style={{ color: "cyan" }} overscanCount={0} outerRef={anyRef} @@ -112,7 +112,7 @@ const VariableSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({ direction={testBool ? "vertical" : "horizontal"} initialScrollOffset={0} innerRef={anyRef} - innerTagName="div" + innerElementType="div" itemData={{ foo: "bar" }} itemKey={index => "foo" + index.toString()} onItemsRendered={({ @@ -127,7 +127,7 @@ const VariableSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({ visibleStopIndex } useIsScrolling={true} - outerTagName="div" + outerElementType="div" style={{ color: "cyan" }} overscanCount={0} outerRef={anyRef} @@ -161,7 +161,7 @@ const VariableSizeGridTestOptionalProps: React.SFC = () => ( initialScrollLeft={0} initialScrollTop={0} innerRef={anyRef} - innerTagName="div" + innerElementType="div" itemData={{ foo: "bar" }} itemKey={({ columnIndex, rowIndex }) => columnIndex.toString() + rowIndex.toString() @@ -184,7 +184,7 @@ const VariableSizeGridTestOptionalProps: React.SFC = () => ( verticalScrollDirection }) => undefined} outerRef={anyRef} - outerTagName="div" + outerElementType="div" overscanColumnsCount={5} overscanRowsCount={5} ref="ref"