Skip to content

Flowtype and .filter() #11

Open
Open
@benadamstyles

Description

@benadamstyles

I have been looking at the maybe source code and trying to work out how to improve the typing of the .filter() method but I haven't worked anything out. The problem is below. Is it possible to fix this within maybe or is flow not able to handle this anyway yet?

maybe(getUserType()) // => 'admin' | 'customer'
  .filter(userType => userType !== 'admin')
  .forEach((userType: 'customer') => // => flow complains that userType is 'admin' | 'customer'
    doSomethingOnlyCustomerCanDo(userType)
  )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions