From cce9ef7b601681addc2764ea215a7a16b1ca82ce Mon Sep 17 00:00:00 2001 From: tricinel Date: Tue, 24 Oct 2017 18:49:29 +0200 Subject: [PATCH 1/9] Add flow types to components; realted to #24 --- flow-typed/glamor.js | 10 ++++++++ src/components/Flex/Flex.js | 17 ++++++++++++- .../LayoutFooter/ExternalFooterLink.js | 12 +++++++++- src/components/LayoutFooter/Footer.js | 3 ++- src/components/LayoutFooter/FooterLink.js | 11 ++++++++- src/components/LayoutFooter/FooterNav.js | 11 ++++++++- src/components/LayoutHeader/DocSearch.js | 7 +++++- src/components/LayoutHeader/Header.js | 3 ++- src/components/LayoutHeader/HeaderLink.js | 9 ++++++- .../StickyResponsiveSidebar.js | 24 +++++++++++++++---- 10 files changed, 95 insertions(+), 12 deletions(-) diff --git a/flow-typed/glamor.js b/flow-typed/glamor.js index 507ea4b7..1c87bfc2 100644 --- a/flow-typed/glamor.js +++ b/flow-typed/glamor.js @@ -5,3 +5,13 @@ declare module 'glamor' { }, }; } + +declare module 'glamor/react' { + declare module.exports: { + createElement: any, + dom: any, + vars: any, + makeTheme: any, + propMerge: Function, + }; +} diff --git a/src/components/Flex/Flex.js b/src/components/Flex/Flex.js index 6acc11e6..8784aa79 100644 --- a/src/components/Flex/Flex.js +++ b/src/components/Flex/Flex.js @@ -2,12 +2,27 @@ * Copyright (c) 2013-present, Facebook, Inc. * * @emails react-core + * @flow */ 'use strict'; import {createElement} from 'glamor/react'; +import type {Node} from 'react'; + +type Props = { + basis: string, + children: Node, + direction: string, + grow: number, + halign: string, + shrink: number, + type: string, + valign: string, + rest: Array, +}; + /** * Convenience component for declaring a flexbox layout. */ @@ -21,7 +36,7 @@ const Flex = ({ type = 'div', valign = 'flex-start', ...rest -}) => +}: Props) => createElement( type, { diff --git a/src/components/LayoutFooter/ExternalFooterLink.js b/src/components/LayoutFooter/ExternalFooterLink.js index 04632fda..1d77ed6c 100644 --- a/src/components/LayoutFooter/ExternalFooterLink.js +++ b/src/components/LayoutFooter/ExternalFooterLink.js @@ -2,6 +2,7 @@ * Copyright (c) 2013-present, Facebook, Inc. * * @emails react-core + * @flow */ 'use strict'; @@ -10,7 +11,16 @@ import React from 'react'; import {colors} from 'theme'; import ExternalLinkSvg from 'templates/components/ExternalLinkSvg'; -const ExternalFooterLink = ({children, href, target, rel}) => ( +import type {Node} from 'react'; + +type Props = { + children: Node, + href: string, + target?: string, + rel?: string, +}; + +const ExternalFooterLink = ({children, href, target, rel}: Props) => ( ( +const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (