Browse Source

Added some basic Flow types to get things started

main
Brian Vaughn 7 years ago
parent
commit
1de4c66dc6
  1. 2
      .flowconfig
  2. 3
      flow-typed/gatsby-link.js
  3. 7
      flow-typed/glamor.js
  4. 1
      flow-typed/graphql.js
  5. 5
      src/components/Container/Container.js
  6. 2
      src/html.js
  7. 1
      src/index.js
  8. 3
      src/pages/404.js
  9. 11
      src/pages/blog/all.html.js
  10. 3
      src/pages/jsx-compiler.html.js
  11. 3
      src/prism-styles.js
  12. 18
      src/site-constants.js
  13. 11
      src/theme.js
  14. 44
      src/types.js
  15. 2
      src/utils/createLink.js

2
.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

3
flow-typed/gatsby-link.js

@ -0,0 +1,3 @@
declare module 'gatsby-link' {
declare module.exports: any;
}

7
flow-typed/glamor.js

@ -0,0 +1,7 @@
declare module 'glamor' {
declare module.exports: {
css: {
global: (...params: any) => void,
},
};
}

1
flow-typed/graphql.js

@ -0,0 +1 @@
declare function graphql(...params: any): any;

5
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}) => (
<div
css={{
paddingLeft: 20,

2
src/html.js

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
*/
'use strict';

1
src/index.js

@ -1 +0,0 @@
var foo = 'bar';

3
src/pages/404.js

@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/
'use strict';

11
src/pages/blog/all.html.js

@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/
'use strict';
@ -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}>

3
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';

3
src/prism-styles.js

@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
* @flow
*/
'use strict';

18
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};

11
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};

44
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
src/utils/createLink.js

@ -109,7 +109,7 @@ const linkCss = {
},
};
export default {
export {
createLinkBlog,
createLinkCommunity,
createLinkDocs,

Loading…
Cancel
Save