Skip to content

Flow type definitions aren't working #142

@saadq

Description

@saadq

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

Flow type definitions aren't working

What is the expected behavior?

Flow type definitions should work

What's your environment?

Node: v9.5.0
Flow: v0.64.0
React: v16.2.0
Final-Form: v4.2.0
React-Final-Form: v3.1.0

Steps to reproduce

  1. npm install flow-bin final-form react-final-form
  2. Write this code:
/**
 * @flow
 */

import { version } from 'react-final-form'

const v: number = version // This should throw error, but doesn't

console.log(v)
  1. Run flow in terminal or editor

As you can see, it doesn't cause any issues:

screen shot 2018-02-06 at 5 01 10 pm

Possible solution

I think this may have to do with the fact that in the dist, the main file is react-final-form.cjs.js. I think this may mean that the .flow file that gets generated may need to be called react-final-form.cjs.js.flow. When I renamed index.js.flow to react-final-form.cjs.js, flow seems to work:

screen shot 2018-02-06 at 5 01 00 pm


NOTE: The types still seem to be problematic however. When I use the simple example (only thing I changed was <Styles> to <div>), there seem to be all sorts of Flow errors. I'm not sure if this has to do with the type definitions being incorrect or not.

Example Code: Gist
Terminal Output: Gist

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