From 1de4c66dc677646a63344e5138f3bf9e0c0d3f76 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Thu, 5 Oct 2017 15:33:18 -0700 Subject: [PATCH] Added some basic Flow types to get things started --- .flowconfig | 2 ++ flow-typed/gatsby-link.js | 3 ++ flow-typed/glamor.js | 7 +++++ flow-typed/graphql.js | 1 + src/components/Container/Container.js | 5 ++- src/html.js | 2 +- src/index.js | 1 - src/pages/404.js | 3 +- src/pages/blog/all.html.js | 11 +++++-- src/pages/jsx-compiler.html.js | 3 +- src/prism-styles.js | 3 +- src/site-constants.js | 18 +++++------ src/theme.js | 11 ++----- src/types.js | 44 +++++++++++++++++++++++++++ src/utils/createLink.js | 2 +- 15 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 flow-typed/gatsby-link.js create mode 100644 flow-typed/glamor.js create mode 100644 flow-typed/graphql.js delete mode 100644 src/index.js create mode 100644 src/types.js diff --git a/.flowconfig b/.flowconfig index cb19818a7..836f6ec1e 100644 --- a/.flowconfig +++ b/.flowconfig @@ -12,6 +12,8 @@ [options] module.system=haste +module.system.node.resolve_dirname=node_modules +module.system.node.resolve_dirname=src esproposal.class_static_fields=enable esproposal.class_instance_fields=enable diff --git a/flow-typed/gatsby-link.js b/flow-typed/gatsby-link.js new file mode 100644 index 000000000..d5fa90363 --- /dev/null +++ b/flow-typed/gatsby-link.js @@ -0,0 +1,3 @@ +declare module 'gatsby-link' { + declare module.exports: any; +} diff --git a/flow-typed/glamor.js b/flow-typed/glamor.js new file mode 100644 index 000000000..507ea4b76 --- /dev/null +++ b/flow-typed/glamor.js @@ -0,0 +1,7 @@ +declare module 'glamor' { + declare module.exports: { + css: { + global: (...params: any) => void, + }, + }; +} diff --git a/flow-typed/graphql.js b/flow-typed/graphql.js new file mode 100644 index 000000000..53685c1a6 --- /dev/null +++ b/flow-typed/graphql.js @@ -0,0 +1 @@ +declare function graphql(...params: any): any; diff --git a/src/components/Container/Container.js b/src/components/Container/Container.js index 8e17a2cb3..266fa0668 100644 --- a/src/components/Container/Container.js +++ b/src/components/Container/Container.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. * * @emails react-core + * @flow */ 'use strict'; @@ -13,11 +14,13 @@ import React from 'react'; import {media} from 'theme'; +import type {Node} from 'react'; + /** * This component wraps page content sections (eg header, footer, main). * It provides consistent margin and max width behavior. */ -const Container = ({children}) => ( +const Container = ({children}: {children: Node}) => (
( +import type {allMarkdownRemarkData} from 'types'; + +type Props = { + data: allMarkdownRemarkData, +}; + +const AllBlogPosts = ({data}: Props) => (
diff --git a/src/pages/jsx-compiler.html.js b/src/pages/jsx-compiler.html.js index 9c358bafd..c3681604f 100644 --- a/src/pages/jsx-compiler.html.js +++ b/src/pages/jsx-compiler.html.js @@ -5,7 +5,8 @@ * LICENSE file in the root directory of this source tree. * * @emails react-core -*/ + * @flow + */ 'use strict'; diff --git a/src/prism-styles.js b/src/prism-styles.js index 14899e900..34b9c90cf 100644 --- a/src/prism-styles.js +++ b/src/prism-styles.js @@ -5,7 +5,8 @@ * LICENSE file in the root directory of this source tree. * * @emails react-core -*/ + * @flow + */ 'use strict'; diff --git a/src/site-constants.js b/src/site-constants.js index c05963212..8d3b25df9 100644 --- a/src/site-constants.js +++ b/src/site-constants.js @@ -4,19 +4,15 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @emails react-core + * @providesModule site-constants * @flow -*/ + */ 'use strict'; -/** - * Variables shared by multiple components. - */ +// NOTE: We can't just use `location.toString()` because when we are rendering +// the SSR part in node.js we won't have a proper location. +const urlRoot = 'https://reactjs.org'; +const version = '16.0.0'; -export default { - // NOTE: We can't just use `location.toString()` because when we are rendering - // the SSR part in node.js we won't have a proper location. - urlRoot: 'https://reactjs.org', - version: '16.0.0', -}; +export {urlRoot, version}; diff --git a/src/theme.js b/src/theme.js index bf811ac1f..50297bc9f 100644 --- a/src/theme.js +++ b/src/theme.js @@ -4,9 +4,9 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @emails react-core + * @providesModule theme * @flow -*/ + */ 'use strict'; @@ -399,9 +399,4 @@ const sharedStyles = { }, }; -export default { - colors, - fonts, - media, - sharedStyles, -}; +export {colors, fonts, media, sharedStyles}; diff --git a/src/types.js b/src/types.js new file mode 100644 index 000000000..22a7a04e2 --- /dev/null +++ b/src/types.js @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @emails react-core + * @flow + */ + +export type Author = { + name: string, + url: string, +}; + +export type Node = { + excerpt: string, + fields: { + date?: string, + path: string, + redirect: string, + slug: string, + }, + frontmatter: { + author?: Array, + next?: string, + prev?: string, + title: string, + }, + html: string, + id: string, +}; + +export type Edge = { + node: Node, +}; + +export type allMarkdownRemarkData = { + allMarkdownRemark: { + edges: Array, + }, +}; + +export type markdownRemarkData = Node; diff --git a/src/utils/createLink.js b/src/utils/createLink.js index 77b673230..88bac8251 100644 --- a/src/utils/createLink.js +++ b/src/utils/createLink.js @@ -109,7 +109,7 @@ const linkCss = { }, }; -export default { +export { createLinkBlog, createLinkCommunity, createLinkDocs,