Skip to content

Commit 066d568

Browse files
author
Vis Viva
committed
Setting up flow
1 parent 57ffa9d commit 066d568

File tree

8 files changed

+52
-9
lines changed

8 files changed

+52
-9
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"plugins": [
33
"transform-class-properties",
4-
"transform-runtime"
4+
"transform-runtime",
5+
"transform-flow-comments"
56
],
67
"presets": [
78
["es2015", { "modules": false }],

.flowconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[options]

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"extract-text-webpack-plugin": "^2.0.0-rc.2",
4040
"fetch-mock": "^5.9.3",
4141
"file-loader": "0.8.5",
42+
"flow-babel-webpack-plugin": "^1.0.1",
4243
"html-webpack-plugin": "^2.24.1",
4344
"http-server": "^0.9.0",
4445
"isomorphic-fetch": "^2.2.1",

src/actions/todos.actions.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
1+
/* @flow */
2+
3+
/**
4+
* Types
5+
*/
6+
7+
import type {
8+
Todo
9+
} from "../types";
10+
111
/**
212
* Actions
313
*/
414

5-
export const ADD_TODO = 'ADD_TODO';
6-
export function addTodo(todo) {
15+
export const ADD_TODO: string = 'ADD_TODO';
16+
export function addTodo(todo: Todo) {
717
return {
818
type: ADD_TODO,
919
payload: todo
1020
};
1121
}
1222

13-
export const ADD_EPIC_TODO = 'ADD_EPIC_TODO';
14-
export function addEpicTodo(todo) {
23+
export const ADD_EPIC_TODO: string = 'ADD_EPIC_TODO';
24+
export function addEpicTodo(todo: Todo) {
1525
return {
1626
type: ADD_EPIC_TODO,
1727
payload: todo
1828
};
1929
}
2030

21-
export const ADD_EPIC_HTTP_TODO = 'ADD_EPIC_HTTP_TODO';
31+
export const ADD_EPIC_HTTP_TODO: string = 'ADD_EPIC_HTTP_TODO';
2232
export function addEpicHttpTodo() {
2333
return {
2434
type: ADD_EPIC_HTTP_TODO
2535
};
2636
}
2737

28-
export const DELETE_TODO = 'DELETE_TODO';
29-
export function deleteTodo(id) {
38+
export const DELETE_TODO: string = 'DELETE_TODO';
39+
export function deleteTodo(id: number) {
3040
return {
3141
type: DELETE_TODO,
3242
payload: id

src/types/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* @flow */
2+
3+
export type Todo = {
4+
id: string,
5+
text: string
6+
}

src/types/todo.type.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* @flow */
2+
3+
4+
export type Todo = {
5+
id: string,
6+
text: string
7+
}

webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const webpack = require('webpack');
77
const DashboardPlugin = require('webpack-dashboard/plugin');
88
const HtmlWebpackPlugin = require('html-webpack-plugin');
99
const ExtractTextPlugin = require('extract-text-webpack-plugin');
10+
const FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin');
1011
const autoprefixer = require('autoprefixer');
1112

1213
/**
@@ -59,7 +60,8 @@ const plugins = [
5960
],
6061
context: constants.SOURCE_PATH
6162
}
62-
})
63+
}),
64+
new FlowBabelWebpackPlugin()
6365
];
6466

6567
/**

webpack.test.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
/**
2+
* Libraries
3+
*/
4+
5+
const FlowBabelWebpackPlugin = require('flow-babel-webpack-plugin');
6+
17
/**
28
* Exporting configuration
39
*/
410

511
module.exports = {
612
devtool: 'source-map',
13+
plugins: [
14+
new FlowBabelWebpackPlugin(),
15+
],
716
module: {
817
rules: [{
918
test: /\.(js|jsx)$/,

0 commit comments

Comments
 (0)