Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Upgrade flow to version 0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thangngoc89 committed Aug 18, 2016
1 parent 462962b commit 1921ff0
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
.*/.nyc_output/.*

[libs]
./node_modules/flow-interfaces/interfaces/
./interfaces/
./flow-typed/

[options]
esproposal.class_instance_fields=enable
Expand Down
15 changes: 15 additions & 0 deletions flow-typed/npm/classnames_v2.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// flow-typed signature: 62bc5615b7c27f8f00718fec93336e7f
// flow-typed version: ef0148e929/classnames_v2.x.x/flow_>=v0.28.x

type $npm$classnames$Classes =
string |
{[className: string]: ?boolean } |
Array<string> |
void |
null

declare module 'classnames' {
declare function exports(
...classes: Array<$npm$classnames$Classes>
): string;
}
81 changes: 81 additions & 0 deletions flow-typed/npm/react-redux_v4.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// flow-typed signature: 708adb773a9ad8abf8edbbb240cc59b4
// flow-typed version: f86b0822d6/react-redux_v4.x.x/flow_>=v0.30.x

/* @flow */
type ConnectAll = <D, P, S, C: React$Component<D, P, S>, SP, DP, Dispatch: Function>(
mapStateToProps: (state: Object, ownProps: $Diff<$Diff<$Diff<P, DP>, SP>, D>) => SP,
mapDispatchToProps: (dispatch: Dispatch, ownProps: $Diff<$Diff<$Diff<P, DP>, SP>, D>) => DP,
mergeProps: null | void,
options?: {pure?: boolean, withRef?: boolean}
) => (component: Class<C>) => Class<React$Component<D, $Diff<$Diff<P, DP>, SP>, S>>;

type ConnectAllStateless = <P, SP, DP, Dispatch: Function>(
mapStateToProps: (state: Object, ownProps: $Diff<$Diff<P, DP>, SP>) => SP,
mapDispatchToProps: (dispatch: Dispatch, ownProps: $Diff<$Diff<P, DP>, SP>) => DP,
mergeProps: null | void,
options?: {pure?: boolean, withRef?: boolean}
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<$Diff<P, DP>, SP>, void>>;

type ConnectMerged = <D, P, S, C: React$Component<D, P, S>, SP, DP, MP, Dispatch: Function>(
mapStateToProps: (state: Object, ownProps: $Diff<$Diff<P, MP>, D>) => SP,
mapDispatchToProps: (dispatch: Dispatch, ownProps: $Diff<$Diff<P, MP>, D>) => DP,
mergeProps: (stateProps: SP, dispatchProps: DP, ownProps: $Diff<$Diff<P, MP>, D>) => MP,
options?: {pure?: boolean, withRef?: boolean}
) => (component: Class<C>) => Class<React$Component<D, $Diff<P, MP>, S>>;

type ConnectMergedStateless = <P, SP, DP, MP, Dispatch: Function>(
mapStateToProps: (state: Object, ownProps: $Diff<P, MP>) => SP,
mapDispatchToProps: (dispatch: Dispatch, ownProps: $Diff<P, MP>) => DP,
mergeProps: (stateProps: SP, dispatchProps: DP, ownProps: $Diff<P, MP>) => MP,
options?: {pure?: boolean, withRef?: boolean}
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<P, MP>, void>>;

type ConnectNoState = <D, P, S, C: React$Component<D, P, S>, DP, Dispatch: Function>(
mapStateToProps: null | void,
mapDispatchToProps: (dispatch: Dispatch, ownProps: $Diff<$Diff<P, DP>, D>) => DP,
mergeProps: null | void,
options?: {pure?: boolean, withRef?: boolean}
) => (component: Class<C>) => Class<React$Component<D, $Diff<P, DP>, S>>;

type ConnectNoStateStatless = <P, DP, Dispatch: Function>(
mapStateToProps: null | void,
mapDispatchToProps: (dispatch: Dispatch, ownProps: $Diff<P, DP>) => DP,
mergeProps: null | void,
options?: {pure?: boolean, withRef?: boolean}
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<P, DP>, void>>;

type ConnectDispatch = <D, P, S, C: React$Component<D, P, S>, SP, Dispatch: Function>(
mapStateToProps: (state: Object, ownProps: $Diff<$Diff<$Diff<P, {dispatch: Dispatch}>, SP>, D>) => SP,
mapDispatchToProps: null | void,
mergeProps: null | void,
options?: {pure?: boolean, withRef?: boolean}
) => (component: Class<C>) => Class<React$Component<D, $Diff<$Diff<P, {dispatch: Dispatch}>, SP>, S>>;

type ConnectDispatchStateless = <P, SP, Dispatch: Function>(
mapStateToProps: (state: Object, ownProps: $Diff<$Diff<P, {dispatch: Dispatch}>, SP>) => SP,
mapDispatchToProps: null | void,
mergeProps: null | void,
options?: {pure?: boolean, withRef?: boolean}
) => (component: (props: P) => any) => Class<React$Component<void, $Diff<$Diff<P, {dispatch: Dispatch}>, SP>, void>>;

type ConnectDefault = <D, P, S, C: React$Component<D, P, S>, Dispatch: Function>() =>
(component: Class<C>) => Class<React$Component<D, $Diff<P, {dispatch: Dispatch}>, S>>;

type ConnectDefaultStateless = () =>
<P>(component: (props: P) => any) => Class<React$Component<void, $Diff<P, {dispatch: Function}>, void>>;

declare module 'react-redux' {
declare var exports: {
connect: ConnectAll
& ConnectAllStateless
& ConnectMerged
& ConnectMergedStateless
& ConnectNoState
& ConnectNoStateStatless
& ConnectDispatch
& ConnectDispatchStateless
& ConnectDefault
& ConnectDefaultStateless;
Provider: ReactClass<{store: Object, children?: any}>;
}
}
32 changes: 32 additions & 0 deletions flow-typed/npm/redux_v3.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// flow-typed signature: 3b60d0484a561f2e7c43ac2a5eb28d87
// flow-typed version: f622abbe3e/redux_v3.x.x/flow_>=v0.23.x

declare module 'redux' {
declare type State = any;
declare type Action = Object;
declare type AsyncAction = any;
declare type Reducer<S, A> = (state: S, action: A) => S;
declare type BaseDispatch = (a: Action) => Action;
declare type Dispatch = (a: Action | AsyncAction) => any;
declare type ActionCreator = (...args: any) => Action | AsyncAction;
declare type MiddlewareAPI = { dispatch: Dispatch, getState: () => State };
declare type Middleware = (api: MiddlewareAPI) => (next: Dispatch) => Dispatch;
declare type Store = {
dispatch: Dispatch,
getState: () => State,
subscribe: (listener: () => void) => () => void,
replaceReducer: (reducer: Reducer<any, any>) => void
};
declare type StoreCreator = (reducer: Reducer<any, any>, initialState: ?State) => Store;
declare type StoreEnhancer = (next: StoreCreator) => StoreCreator;
declare type ActionCreatorOrObjectOfACs = ActionCreator | { [key: string]: ActionCreator };
declare type Reducers = { [key: string]: Reducer<any, any> };
declare class Redux {
bindActionCreators<actionCreators: ActionCreatorOrObjectOfACs>(actionCreators: actionCreators, dispatch: Dispatch): actionCreators;
combineReducers(reducers: Reducers): Reducer<any, any>;
createStore(reducer: Reducer<any, any>, initialState?: State, enhancer?: StoreEnhancer): Store;
applyMiddleware(...middlewares: Array<Middleware>): StoreEnhancer;
compose(...functions: Array<Function | StoreEnhancer>): Function;
}
declare var exports: Redux;
}
4 changes: 2 additions & 2 deletions interfaces/node-modules/fs-promise.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare module "fs-promise" {
declare function writeFile(to: string, content: string): Promise;
declare function mkdirs(path: string): Promise;
declare function writeFile(to: string, content: string): Promise<any>;
declare function mkdirs(path: string): Promise<any>;

declare interface fsPromise {
writeFile: writeFile,
Expand Down
2 changes: 1 addition & 1 deletion interfaces/node-modules/redbox-react.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare module "redbox-react" {
declare var exports: ReactClass;
declare var exports: ReactClass<any>;
}
2 changes: 1 addition & 1 deletion interfaces/node-modules/simple-json-fetch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
declare module "simple-json-fetch" {
declare class SimpleJsonFetch {
(uri: string): Promise;
(uri: string): Promise<any>;
}
declare var exports: SimpleJsonFetch;
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@
"exec-cmd": "^2.0.1",
"expect": "^1.13.4",
"expect-jsx": "^2.2.1",
"flow-bin": "^0.27.0",
"flow-interfaces": "^0.5.0",
"flow-bin": "^0.30.0",
"image-optim": "^3.0.0",
"js-beautify": "^1.5.10",
"jsdom": "^9.2.0",
Expand Down Expand Up @@ -172,7 +171,7 @@
"prepublish": "rimraf lib && npm run transpile",
"#lint:js:eslint": "https://github.com/eslint/eslint/issues/5679",
"lint:js:eslint": "eslint --ignore-path .gitignore --fix src __tests__ scripts npm interfaces docs/scripts docs/src docs/web_modules boilerplate/scripts boilerplate/src boilerplate/web_modules",
"lint:js:flow": "babel-node scripts/flow-check.js",
"lint:js:flow": "flow check",
"lint:js": "npm-run-all --parallel lint:js:*",
"lint:css": "stylelint \"+(boilerplate|docs)/web_modules/**/*.css\"",
"lint": "npm-run-all --parallel lint:*",
Expand Down
11 changes: 0 additions & 11 deletions scripts/flow-check.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/ContextProvider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class PhenomicContext extends Component {
}
}

render(): React$Element {
render(): React$Element<any> {
return Children.only(this.props.children)
}
}
2 changes: 1 addition & 1 deletion src/Link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function Link(
children: any,
},
{ router }: { router: Object }
): React$Element {
): React$Element<any> {
return (
<RouterLink
{ ...props }
Expand Down
6 changes: 3 additions & 3 deletions src/PageContainer/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ function adjustCurrentUrl(location: Object, item: Object, props: Props): void {

function getLayout(
layout: string, props: Props
): ReactClass | void {
): ReactClass<any> | void {
if (props.layouts && props.layouts[layout]) {
return props.layouts[layout]
}
}

class PageContainer extends Component<DefaultProps, Props, void> {
_content: Element;
_content: HTMLElement;

propTypes: Props;

Expand Down Expand Up @@ -198,7 +198,7 @@ class PageContainer extends Component<DefaultProps, Props, void> {
}
}

saveContentRef: Function = (ref: Element): void => {
saveContentRef: Function = (ref: HTMLElement): void => {
this._content = ref
};

Expand Down
2 changes: 1 addition & 1 deletion src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function phenomic({
store,
}: {
metadata: Object,
routes: React$Element,
routes: React$Element<any>,
store: Object,
}): void {
const collection =
Expand Down
4 changes: 2 additions & 2 deletions src/components/BodyContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import React, { Component } from "react"

type Props = {
children: React$Element
children: React$Element<any>
}

class BodyContainer extends Component<void, Props, void> {

render(): React$Element {
render(): React$Element<any> {
const { props }: { props: Props } = this

return (
Expand Down
3 changes: 0 additions & 3 deletions src/phenomic-loader-preset-markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import transformBodyPropertyToHtml
from "../phenomic-loader-plugin-markdown-transform-body-property-to-html"

export default [
// $FlowFixMe Missing annotation wtf?
...defaultPlugins,
// $FlowFixMe Missing annotation wtf?
initHeadDescriptionPropertyFromContent,
// $FlowFixMe Missing annotation wtf?
transformBodyPropertyToHtml,
]
2 changes: 1 addition & 1 deletion src/redux/modules/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function refresh(page: string, url: string): PromiseAction {
}
}

export function setNotFound(page: string): Action {
export function setNotFound(page: string): Object {
return {
type: ERROR,
page,
Expand Down
2 changes: 1 addition & 1 deletion src/static/postbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function(
config: PhenomicConfig,
files: Array<any>,
log: Function
): Promise {
): Promise<any> {
log(green(`✓ Static html files: ${ files.length } files written.`))

const promises = []
Expand Down

0 comments on commit 1921ff0

Please sign in to comment.