Skip to content

Commit

Permalink
Added some basic Flow types to get things started
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Oct 5, 2017
1 parent 8d54bd0 commit 1de4c66
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .flowconfig
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions flow-typed/gatsby-link.js
@@ -0,0 +1,3 @@
declare module 'gatsby-link' {
declare module.exports: any;
}
7 changes: 7 additions & 0 deletions flow-typed/glamor.js
@@ -0,0 +1,7 @@
declare module 'glamor' {
declare module.exports: {
css: {
global: (...params: any) => void,
},
};
}
1 change: 1 addition & 0 deletions flow-typed/graphql.js
@@ -0,0 +1 @@
declare function graphql(...params: any): any;
5 changes: 4 additions & 1 deletion src/components/Container/Container.js
Expand Up @@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
* @flow
*/

'use strict';
Expand All @@ -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}) => (
<div
css={{
paddingLeft: 20,
Expand Down
2 changes: 1 addition & 1 deletion src/html.js
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
*/

'use strict';

Expand Down
1 change: 0 additions & 1 deletion src/index.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/pages/404.js
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/

'use strict';

Expand Down
11 changes: 9 additions & 2 deletions src/pages/blog/all.html.js
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/

'use strict';

Expand All @@ -19,7 +20,13 @@ import {colors, media, sharedStyles} from 'theme';
import toCommaSeparatedList from 'utils/toCommaSeparatedList';
import MetaTitle from 'templates/components/MetaTitle';

const AllBlogPosts = ({data}) => (
import type {allMarkdownRemarkData} from 'types';

type Props = {
data: allMarkdownRemarkData,
};

const AllBlogPosts = ({data}: Props) => (
<Container>
<div css={sharedStyles.articleLayout.container}>
<div css={sharedStyles.articleLayout.content}>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/jsx-compiler.html.js
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/

'use strict';

Expand Down
3 changes: 2 additions & 1 deletion src/prism-styles.js
Expand Up @@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/

'use strict';

Expand Down
18 changes: 7 additions & 11 deletions src/site-constants.js
Expand Up @@ -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};
11 changes: 3 additions & 8 deletions src/theme.js
Expand Up @@ -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';

Expand Down Expand Up @@ -399,9 +399,4 @@ const sharedStyles = {
},
};

export default {
colors,
fonts,
media,
sharedStyles,
};
export {colors, fonts, media, sharedStyles};
44 changes: 44 additions & 0 deletions 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<Author>,
next?: string,
prev?: string,
title: string,
},
html: string,
id: string,
};

export type Edge = {
node: Node,
};

export type allMarkdownRemarkData = {
allMarkdownRemark: {
edges: Array<Edge>,
},
};

export type markdownRemarkData = Node;
2 changes: 1 addition & 1 deletion src/utils/createLink.js
Expand Up @@ -109,7 +109,7 @@ const linkCss = {
},
};

export default {
export {
createLinkBlog,
createLinkCommunity,
createLinkDocs,
Expand Down

0 comments on commit 1de4c66

Please sign in to comment.