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

compose function results typed as 'any' #580

Open
fragosti opened this issue Dec 28, 2017 · 3 comments
Open

compose function results typed as 'any' #580

fragosti opened this issue Dec 28, 2017 · 3 comments

Comments

@fragosti
Copy link

fragosti commented Dec 28, 2017

I've been setting up a new project to use recompose + flow and everything is working great except that flow coverage is not 100% because apparently flow is inferring type any the compose function.

Here is the example code:

// @flow
import React from 'react';
import { compose, pure, withStateHandlers } from 'recompose';
import type { HOC } from 'recompose';
...
const enhance: HOC<*, Props> = compose(
  pure,
  withStateHandlers(
    { isShowing: false },
    {
      show: () => () => ({ isShowing: true }),
      hide: () => () => ({ isShowing: false }),
    }
  )
);

export default enhance(App);

Both Visual Studio Code and flow coverage tell me that I have some uncovered code, and VSC shows that it's because compose has type 'any'. Also I tried manually using the $Compose util type but VSC says it's typed to any as well.

react: 16.2.0
recompose: 0.26.0
flow-bin: 0.61.0
flow-typed: 2.2.3

flow-typed install recompose results in these being the definitions.

@istarkov
Copy link
Contributor

we have here examples, tests etc with flow, may you just look there

@fragosti
Copy link
Author

fragosti commented Dec 28, 2017

@istarkov the issue is basically that the flow types are being loaded for some of the api but not other parts. I seem to be able to load the types for pure and withStateHandlers but not for compose. Might not be an issue with recompose.

@istarkov
Copy link
Contributor

Have you tried to use flow type defs not from flowtyped repo but directly downloading them here and including https://github.com/acdlite/recompose/blob/master/types/flow-example/.flowconfig#L9

And it will be good to provide simple example at github so anyone can reproduce just cloning it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants