Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Flow 0.57.3 shows no errors #91

@on3iro

Description

@on3iro

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions