-
Notifications
You must be signed in to change notification settings - Fork 48
Closed
facebook/flow
#5850Description
I tried flow 0.57.3 inside various projects where I used 0.56.0 before.
I made a few errors on purpose, which the old version showed correctly.
On 0.57.3 however flow says No Errors.
Am I doing something wrong or does the current version not work?
On a side-note:
Following the offical documentation I am using
a disjoint Union for redux actions. I was expecting flow to throw an error if I do not provide
cases for every action in my reducer, but flow somehow seems to be fine with that.
// types
const INIT = 'INIT'
const USER_FETCH_SUCCESS = 'USER_FETCH_SUCCESS'
const USER_FETCH_FAIL = 'USER_FETCH_FAIL'
type User = {
+id: string,
+name: string,
+age: number
}
type Init = {| type: typeof INIT |}
type UserFetchSuccess = {| type: typeof USER_FETCH_SUCCESS, payload: User |}
type UserFetchFail = {| type: typeof USER_FETCH_FAIL, payload: Object |}
type Action = Init | UserFetchSuccess | UserFetchFail
// Reducer
const fakeUserReducer = (state: State = {
loading: false,
user: null,
error: null
}, action: Action): State => {
switch (action.type) {
case INIT:
return loop(
{...state, loading: true},
Cmd.run(fetchUser, {
successActionCreator: userFetchSuccessfulAction,
failActionCreator: userFetchFailedAction,
args: ['userA']
})
)
case USER_FETCH_SUCCESS:
return { ...state, user: action.payload, loading: false }
// Flow wont throw an error, even if this case is missing
// case USER_FETCH_FAIL:
// return { ...state, error: action.payload, loading: false }
default:
return state
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels