Skip to content

Commit d5f98ca

Browse files
authored
Merge pull request reactjs#156 from tricinel/feature/flow-types
Switch to flow types; wip related to reactjs#24
2 parents e3cd73a + ab5815b commit d5f98ca

File tree

7 files changed

+42
-28
lines changed

7 files changed

+42
-28
lines changed

flow-typed/react-helmet.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
declare module 'react-helmet' {
2+
declare module.exports: any;
3+
}

src/components/Header/Header.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
89

910
import React from 'react';
1011
import {colors, fonts} from 'theme';
1112

12-
const Header = ({children}) => (
13+
import type {Node} from 'react';
14+
15+
const Header = ({children}: {children: Node}) => (
1316
<h1
1417
css={{
1518
color: colors.dark,

src/components/MarkdownHeader/MarkdownHeader.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
89

910
import Flex from 'components/Flex';
10-
import PropTypes from 'prop-types';
1111
import React from 'react';
1212
import {colors, fonts, media} from 'theme';
1313

14-
const MarkdownHeader = ({title}) => (
14+
const MarkdownHeader = ({title}: {title: string}) => (
1515
<Flex type="header" halign="space-between" valign="baseline">
1616
<h1
1717
css={{
@@ -33,8 +33,4 @@ const MarkdownHeader = ({title}) => (
3333
</Flex>
3434
);
3535

36-
MarkdownHeader.propTypes = {
37-
title: PropTypes.string.isRequired,
38-
};
39-
4036
export default MarkdownHeader;

src/components/MarkdownPage/MarkdownPage.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -10,7 +11,6 @@ import Container from 'components/Container';
1011
import Flex from 'components/Flex';
1112
import MarkdownHeader from 'components/MarkdownHeader';
1213
import NavigationFooter from 'templates/components/NavigationFooter';
13-
import PropTypes from 'prop-types';
1414
import React from 'react';
1515
import StickyResponsiveSidebar from 'components/StickyResponsiveSidebar';
1616
import TitleAndMetaTags from 'components/TitleAndMetaTags';
@@ -19,8 +19,22 @@ import toCommaSeparatedList from 'utils/toCommaSeparatedList';
1919
import {sharedStyles} from 'theme';
2020
import createOgUrl from 'utils/createOgUrl';
2121

22+
import type {Node} from 'types';
23+
24+
type Props = {
25+
authors: Array<string>,
26+
createLink: Function, // TODO: Add better flow type once we Flow-type createLink
27+
date?: string,
28+
enableScrollSync?: boolean,
29+
ogDescription: string,
30+
location: Location,
31+
markdownRemark: Node,
32+
sectionList: Array<Object>, // TODO: Add better flow type once we have the Section component
33+
titlePostfix: string,
34+
};
35+
2236
const MarkdownPage = ({
23-
authors,
37+
authors = [],
2438
createLink,
2539
date,
2640
enableScrollSync,
@@ -29,7 +43,7 @@ const MarkdownPage = ({
2943
markdownRemark,
3044
sectionList,
3145
titlePostfix = '',
32-
}) => {
46+
}: Props) => {
3347
const hasAuthors = authors.length > 0;
3448
const titlePrefix = markdownRemark.frontmatter.title || '';
3549

@@ -122,19 +136,4 @@ const MarkdownPage = ({
122136
);
123137
};
124138

125-
MarkdownPage.defaultProps = {
126-
authors: [],
127-
};
128-
129-
// TODO Better types
130-
MarkdownPage.propTypes = {
131-
authors: PropTypes.array.isRequired,
132-
createLink: PropTypes.func.isRequired,
133-
date: PropTypes.string,
134-
enableScrollSync: PropTypes.bool,
135-
location: PropTypes.object.isRequired,
136-
markdownRemark: PropTypes.object.isRequired,
137-
sectionList: PropTypes.array.isRequired,
138-
};
139-
140139
export default MarkdownPage;

src/components/TitleAndMetaTags/TitleAndMetaTags.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
@@ -11,7 +12,13 @@ import React from 'react';
1112

1213
const defaultDescription = 'A JavaScript library for building user interfaces';
1314

14-
const TitleAndMetaTags = ({title, ogDescription, ogUrl}) => {
15+
type Props = {
16+
title: string,
17+
ogDescription: string,
18+
ogUrl: string,
19+
};
20+
21+
const TitleAndMetaTags = ({title, ogDescription, ogUrl}: Props) => {
1522
return (
1623
<Helmet title={title}>
1724
<meta property="og:title" content={title} />

src/templates/components/ChevronSvg/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
* Copyright (c) 2013-present, Facebook, Inc.
33
*
44
* @emails react-core
5+
* @flow
56
*/
67

78
'use strict';
89

910
import React from 'react';
1011

11-
const ChevronSvg = ({size = 10, cssProps = {}}) => (
12+
type Props = {
13+
size: number,
14+
cssProps: Object,
15+
};
16+
17+
const ChevronSvg = ({size = 10, cssProps = {}}: Props) => (
1218
<svg
1319
css={cssProps}
1420
viewBox="0 0 926.23699 573.74994"

src/templates/components/ExternalLinkSvg/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import React from 'react';
1010

11-
const ExternalLinkSvg = ({cssProps = {}}) => (
11+
const ExternalLinkSvg = ({cssProps = {}}: {cssProps: Object}) => (
1212
<svg
1313
x="0px"
1414
y="0px"

0 commit comments

Comments
 (0)