Create-react-app: Question: flow + jest

Created on 23 Jan 2018  路  5Comments  路  Source: facebook/create-react-app

Do someone have a quick idea how to force flow-typed to install the definitions of jest? I do not see this mentioned in the README, and as jest is not a dependency of my project flow-typed install does not help much.

question stale

All 5 comments

  1. Look at yarn.lock to see which version of jest your project is using, in my case it was 20.0.4
  2. yarn add [email protected] && flow-typed install

It's important to only install the version of jest that CRA is already using otherwise yarn test will error.

@mcjohnalds

It's better to have a peerDependency in your package.json:

  "peerDependencies": {
    "jest": "20.x"
  },

Then flow-typed update --skip

To solve (temporarily I think) the issue of Flow finding errors in a Jest test file with the // @flow annotation at the top, I did:
npm install -g flow-typed
flow-typed install [email protected]

When create-react-app is upgraded to use a new version of Jest, I would have to get the potential new type definitions by running the flowtyped install command above, correct? Is this intended? Isn't CRA supposed to work out of the box without this sort of thing?

I think the issue here is there is no way for flow-typed to install the dependencies of react-scripts which is where jest is pulled in from. This could be alleviated if there was a script added that did this likenpm run flow-typed. However it seems that the current thinking is to only have a very limited number of npm scripts included with create-react-app. Would be nice to have a solution to where we didn't have to include dependencies we wanted flow types for twice. Once in our own project dependencies and once by react-scripts.

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onelson picture onelson  路  3Comments

fson picture fson  路  3Comments

stopachka picture stopachka  路  3Comments

jnachtigall picture jnachtigall  路  3Comments

dualcnhq picture dualcnhq  路  3Comments