Skip to content

Commit 1de4c66

Browse files
committed
Added some basic Flow types to get things started
1 parent 8d54bd0 commit 1de4c66

15 files changed

+88
-28
lines changed

.flowconfig

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
[options]
1414
module.system=haste
15+
module.system.node.resolve_dirname=node_modules
16+
module.system.node.resolve_dirname=src
1517

1618
esproposal.class_static_fields=enable
1719
esproposal.class_instance_fields=enable

flow-typed/gatsby-link.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'gatsby-link' {
2+
declare module.exports: any;
3+
}

flow-typed/glamor.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare module 'glamor' {
2+
declare module.exports: {
3+
css: {
4+
global: (...params: any) => void,
5+
},
6+
};
7+
}

flow-typed/graphql.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare function graphql(...params: any): any;

src/components/Container/Container.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @emails react-core
8+
* @flow
89
*/
910

1011
'use strict';
@@ -13,11 +14,13 @@ import React from 'react';
1314

1415
import {media} from 'theme';
1516

17+
import type {Node} from 'react';
18+
1619
/**
1720
* This component wraps page content sections (eg header, footer, main).
1821
* It provides consistent margin and max width behavior.
1922
*/
20-
const Container = ({children}) => (
23+
const Container = ({children}: {children: Node}) => (
2124
<div
2225
css={{
2326
paddingLeft: 20,

src/html.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @emails react-core
8-
*/
8+
*/
99

1010
'use strict';
1111

src/index.js

-1
This file was deleted.

src/pages/404.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @emails react-core
8-
*/
8+
* @flow
9+
*/
910

1011
'use strict';
1112

src/pages/blog/all.html.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @emails react-core
8-
*/
8+
* @flow
9+
*/
910

1011
'use strict';
1112

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

22-
const AllBlogPosts = ({data}) => (
23+
import type {allMarkdownRemarkData} from 'types';
24+
25+
type Props = {
26+
data: allMarkdownRemarkData,
27+
};
28+
29+
const AllBlogPosts = ({data}: Props) => (
2330
<Container>
2431
<div css={sharedStyles.articleLayout.container}>
2532
<div css={sharedStyles.articleLayout.content}>

src/pages/jsx-compiler.html.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @emails react-core
8-
*/
8+
* @flow
9+
*/
910

1011
'use strict';
1112

src/prism-styles.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* LICENSE file in the root directory of this source tree.
66
*
77
* @emails react-core
8-
*/
8+
* @flow
9+
*/
910

1011
'use strict';
1112

src/site-constants.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @emails react-core
7+
* @providesModule site-constants
88
* @flow
9-
*/
9+
*/
1010

1111
'use strict';
1212

13-
/**
14-
* Variables shared by multiple components.
15-
*/
13+
// NOTE: We can't just use `location.toString()` because when we are rendering
14+
// the SSR part in node.js we won't have a proper location.
15+
const urlRoot = 'https://reactjs.org';
16+
const version = '16.0.0';
1617

17-
export default {
18-
// NOTE: We can't just use `location.toString()` because when we are rendering
19-
// the SSR part in node.js we won't have a proper location.
20-
urlRoot: 'https://reactjs.org',
21-
version: '16.0.0',
22-
};
18+
export {urlRoot, version};

src/theme.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @emails react-core
7+
* @providesModule theme
88
* @flow
9-
*/
9+
*/
1010

1111
'use strict';
1212

@@ -399,9 +399,4 @@ const sharedStyles = {
399399
},
400400
};
401401

402-
export default {
403-
colors,
404-
fonts,
405-
media,
406-
sharedStyles,
407-
};
402+
export {colors, fonts, media, sharedStyles};

src/types.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @emails react-core
8+
* @flow
9+
*/
10+
11+
export type Author = {
12+
name: string,
13+
url: string,
14+
};
15+
16+
export type Node = {
17+
excerpt: string,
18+
fields: {
19+
date?: string,
20+
path: string,
21+
redirect: string,
22+
slug: string,
23+
},
24+
frontmatter: {
25+
author?: Array<Author>,
26+
next?: string,
27+
prev?: string,
28+
title: string,
29+
},
30+
html: string,
31+
id: string,
32+
};
33+
34+
export type Edge = {
35+
node: Node,
36+
};
37+
38+
export type allMarkdownRemarkData = {
39+
allMarkdownRemark: {
40+
edges: Array<Edge>,
41+
},
42+
};
43+
44+
export type markdownRemarkData = Node;

src/utils/createLink.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const linkCss = {
109109
},
110110
};
111111

112-
export default {
112+
export {
113113
createLinkBlog,
114114
createLinkCommunity,
115115
createLinkDocs,

0 commit comments

Comments
 (0)