From 41e137c8e96ab12342e4141842c2c50dbfb6bd3f Mon Sep 17 00:00:00 2001 From: ZheyangSong Date: Thu, 27 Jul 2017 08:03:46 -0700 Subject: [PATCH] Fix react-grid-layout Type Definition (#18433) + each property of `Layouts` should be in shape of `Layout[]` + Refs: + https://github.com/STRML/react-grid-layout/blob/master/test/examples/0-showcase.jsx#L55 + https://github.com/STRML/react-grid-layout/blob/master/test/examples/0-showcase.jsx#L84 + https://github.com/STRML/react-grid-layout/blob/master/lib/responsiveUtils.js#L71 + https://github.com/STRML/react-grid-layout/blob/master/lib/utils.js#L39 --- types/react-grid-layout/index.d.ts | 8 +++++--- types/react-grid-layout/react-grid-layout-tests.tsx | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/types/react-grid-layout/index.d.ts b/types/react-grid-layout/index.d.ts index 63a6d0e6d7..d6d89c6727 100644 --- a/types/react-grid-layout/index.d.ts +++ b/types/react-grid-layout/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for react-grid-layout 0.14 // Project: https://github.com/STRML/react-grid-layout -// Definitions by: Andrew Birkholz , Ali Taheri +// Definitions by: Andrew Birkholz , +// Ali Taheri , +// Zheyang Song // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -78,7 +80,7 @@ declare namespace ReactGridLayout { } type Layouts = { - [P in Breakpoints]: Layout; + [P in Breakpoints]?: Layout[]; }; type ItemCallback = ( @@ -250,7 +252,7 @@ declare namespace ReactGridLayout { /** * layouts is an object mapping breakpoints to layouts. * - * e.g. `{lg: Layout, md: Layout, ...}` + * e.g. `{lg: Layout[], md: Layout[], ...}` */ layouts?: Layouts; diff --git a/types/react-grid-layout/react-grid-layout-tests.tsx b/types/react-grid-layout/react-grid-layout-tests.tsx index 629769970c..6c47e42d95 100644 --- a/types/react-grid-layout/react-grid-layout-tests.tsx +++ b/types/react-grid-layout/react-grid-layout-tests.tsx @@ -31,8 +31,17 @@ class DefaultGridTest extends React.Component { class ResponsiveGridTest extends React.Component { render() { + const layouts = { + lg: [ + { i: '1', x: 0, y: 0, w: 1, h: 2, static: true }, + { i: '2', x: 1, y: 0, w: 3, h: 2, minW: 2, maxW: 4 }, + { i: '3', x: 4, y: 0, w: 1, h: 2 } + ] + }; + return (