From 3e9f4d543bf015caae8de4a2c4135374867ac33a Mon Sep 17 00:00:00 2001 From: vikram-gsu Date: Thu, 11 Apr 2019 07:22:12 -0400 Subject: [PATCH 1/5] Added types for react-leaflet-sidebarv2 --- types/react-leaflet-sidebarv2/index.d.ts | 41 +++++++++++++++++++ .../react-leaflet-sidebarv2-tests.tsx | 14 +++++++ types/react-leaflet-sidebarv2/tsconfig.json | 24 +++++++++++ types/react-leaflet-sidebarv2/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/react-leaflet-sidebarv2/index.d.ts create mode 100644 types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx create mode 100644 types/react-leaflet-sidebarv2/tsconfig.json create mode 100644 types/react-leaflet-sidebarv2/tslint.json diff --git a/types/react-leaflet-sidebarv2/index.d.ts b/types/react-leaflet-sidebarv2/index.d.ts new file mode 100644 index 0000000000..726ec3e18a --- /dev/null +++ b/types/react-leaflet-sidebarv2/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for react-leaflet-sidebarv2 +// Project: https://github.com/condense/react-leaflet-sidebarv2 +// Definitions by: Vikram Pareddy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import React from 'react'; + +type Icon = string | React.ElementType; +type Anchor = 'top' | 'bottom'; +type Position = 'left' | 'right'; + +interface TabProps{ + id: string, + header: string, + icon:Icon, + anchor?: Anchor, + disabled?: boolean, + onClose?: () => void, + closeIcon?: Icon, + position?: Position, + active?: boolean +} +declare class Tab extends React.Component{} + +type TabType = React.Element | React.Element[] + +interface SidebarProps { + id: string, + collapsed: boolean, + position: Position, + selected: string, + closeIcon?: Icon, + onClose?:() => void, + onOpen?: () => void, + children: TabType +} + +declare class Sidebar extends React.Component{} + +export {Tab, Sidebar} \ No newline at end of file diff --git a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx new file mode 100644 index 0000000000..f3bc189bba --- /dev/null +++ b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import {Sidebar, Tab} from 'react-leaflet-sidebarv2'; + +export const MetroSidebar = () => { + return ( + + + No place like home! + + + In Settings. + + ); +} diff --git a/types/react-leaflet-sidebarv2/tsconfig.json b/types/react-leaflet-sidebarv2/tsconfig.json new file mode 100644 index 0000000000..a052e3f930 --- /dev/null +++ b/types/react-leaflet-sidebarv2/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-leaflet-sidebarv2-tests.tsx" + ] +} diff --git a/types/react-leaflet-sidebarv2/tslint.json b/types/react-leaflet-sidebarv2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-leaflet-sidebarv2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From cf9021a7b3aeb9dcac4d5f77098d0fc8d021fdbf Mon Sep 17 00:00:00 2001 From: vikram-gsu Date: Thu, 11 Apr 2019 07:37:31 -0400 Subject: [PATCH 2/5] Modified tests - still seeing 'not a constructor' error --- .../react-leaflet-sidebarv2-tests.tsx | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx index f3bc189bba..9eedfa1585 100644 --- a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx +++ b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx @@ -1,14 +1,25 @@ import * as React from 'react'; import {Sidebar, Tab} from 'react-leaflet-sidebarv2'; -export const MetroSidebar = () => { - return ( - - +const MySidebar = ( + + No place like home! - + In Settings. - ); -} + + ); From ccfe9263f85cc89c2f1d91756d1071d2cfc91db5 Mon Sep 17 00:00:00 2001 From: vikram-gsu Date: Thu, 11 Apr 2019 21:31:50 -0400 Subject: [PATCH 3/5] Fixed types according to linting errors and updated to import all of react since it is type import --- types/react-leaflet-sidebarv2/index.d.ts | 44 +++++++++---------- .../react-leaflet-sidebarv2-tests.tsx | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/types/react-leaflet-sidebarv2/index.d.ts b/types/react-leaflet-sidebarv2/index.d.ts index 726ec3e18a..2ce7767cf4 100644 --- a/types/react-leaflet-sidebarv2/index.d.ts +++ b/types/react-leaflet-sidebarv2/index.d.ts @@ -4,38 +4,38 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import React from 'react'; +import * as React from 'react'; type Icon = string | React.ElementType; type Anchor = 'top' | 'bottom'; type Position = 'left' | 'right'; interface TabProps{ - id: string, - header: string, - icon:Icon, - anchor?: Anchor, - disabled?: boolean, - onClose?: () => void, - closeIcon?: Icon, - position?: Position, + id: string; + header: string; + icon:Icon; + anchor?: Anchor; + disabled?: boolean; + onClose?: () => void; + closeIcon?: Icon; + position?: Position; active?: boolean -} -declare class Tab extends React.Component{} +}; +declare class Tab extends React.Component{}; -type TabType = React.Element | React.Element[] +type TabType = React.Element | Array>; interface SidebarProps { - id: string, - collapsed: boolean, - position: Position, - selected: string, - closeIcon?: Icon, - onClose?:() => void, - onOpen?: () => void, + id: string; + collapsed: boolean; + position: Position; + selected: string; + closeIcon?: Icon; + onClose?:() => void; + onOpen?: () => void; children: TabType -} +}; -declare class Sidebar extends React.Component{} +declare class Sidebar extends React.Component{}; -export {Tab, Sidebar} \ No newline at end of file +export {Tab, Sidebar}; \ No newline at end of file diff --git a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx index 9eedfa1585..6687ba2ac9 100644 --- a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx +++ b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import {Sidebar, Tab} from 'react-leaflet-sidebarv2'; +import { Sidebar, Tab } from 'react-leaflet-sidebarv2'; const MySidebar = ( Date: Fri, 12 Apr 2019 07:45:02 -0400 Subject: [PATCH 4/5] Fixed linting bugs and updated to React.ReactElement --- types/react-leaflet-sidebarv2/index.d.ts | 25 ++++++++++--------- .../react-leaflet-sidebarv2-tests.tsx | 24 +++++++++--------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/types/react-leaflet-sidebarv2/index.d.ts b/types/react-leaflet-sidebarv2/index.d.ts index 2ce7767cf4..82d903c831 100644 --- a/types/react-leaflet-sidebarv2/index.d.ts +++ b/types/react-leaflet-sidebarv2/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-leaflet-sidebarv2 +// Type definitions for react-leaflet-sidebarv2 0.6 // Project: https://github.com/condense/react-leaflet-sidebarv2 // Definitions by: Vikram Pareddy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,20 +10,21 @@ type Icon = string | React.ElementType; type Anchor = 'top' | 'bottom'; type Position = 'left' | 'right'; -interface TabProps{ +interface TabProps { id: string; header: string; - icon:Icon; + icon: Icon; anchor?: Anchor; disabled?: boolean; onClose?: () => void; closeIcon?: Icon; position?: Position; - active?: boolean -}; -declare class Tab extends React.Component{}; + active?: boolean; +} -type TabType = React.Element | Array>; +declare class Tab extends React.Component {} + +type TabType = React.ReactElement | Array>; interface SidebarProps { id: string; @@ -31,11 +32,11 @@ interface SidebarProps { position: Position; selected: string; closeIcon?: Icon; - onClose?:() => void; + onClose?: () => void; onOpen?: () => void; - children: TabType -}; + children: TabType; +} -declare class Sidebar extends React.Component{}; +declare class Sidebar extends React.Component{} -export {Tab, Sidebar}; \ No newline at end of file +export { Tab, Sidebar }; diff --git a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx index 6687ba2ac9..ccb2df3fea 100644 --- a/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx +++ b/types/react-leaflet-sidebarv2/react-leaflet-sidebarv2-tests.tsx @@ -2,22 +2,22 @@ import * as React from 'react'; import { Sidebar, Tab } from 'react-leaflet-sidebarv2'; const MySidebar = ( - - No place like home! - In Settings. From 3501f2b78d36074c175b5def7431cab6c48e5e61 Mon Sep 17 00:00:00 2001 From: vikram-gsu Date: Fri, 12 Apr 2019 23:18:44 -0400 Subject: [PATCH 5/5] Edited one whitespace according to travis ci lint error --- types/react-leaflet-sidebarv2/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-leaflet-sidebarv2/index.d.ts b/types/react-leaflet-sidebarv2/index.d.ts index 82d903c831..b9be2afb0a 100644 --- a/types/react-leaflet-sidebarv2/index.d.ts +++ b/types/react-leaflet-sidebarv2/index.d.ts @@ -37,6 +37,6 @@ interface SidebarProps { children: TabType; } -declare class Sidebar extends React.Component{} +declare class Sidebar extends React.Component {} export { Tab, Sidebar };