Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install flow type definitions from Jest by default or suggest it #453

Closed
kasperpeulen opened this issue Aug 16, 2016 · 8 comments
Closed

Comments

@kasperpeulen
Copy link
Contributor

I think the suggested flow config should also include the following line:

[libs]
/flow-typed/

So that flow will recognize the definitions if you run:

flow-typed install jest -f 0.30

It would be helpful to add some info in the README about this process of adding type definitions to the project. Maybe the type definition of Jest could actually be added by default?

@gaearon
Copy link
Contributor

gaearon commented Aug 16, 2016

cc @thejameskyle

@jamiebuilds
Copy link

The Flow team has plans for a flow-typed install command that will automatically install libdefs for all of your dependencies and stub the ones that do not have libdefs. So this workflow will be improved in the future not just for Jest but for everything.

In the meantime it might make sense for create-react-app to ship with a [lib] directory with all of the dependencies that create-react-app adds by default. Then can be added to a .flowconfig fairly easily.

cc @jeffmo

@jeffmo
Copy link

jeffmo commented Aug 16, 2016

There's no need for config here (I've never felt so proud!) -- <PROJECT_ROOT>/flow-typed is already a default [libs] dir in Flow.

So as long as that directory exists, any .js files in it are considered libdefs even without a [libs] section in the .flowconfig.

@jamiebuilds
Copy link

There's no need for config here

That's not what I was talking about. I was saying there could be a flow-typed directory (or another name) within react-scripts itself that included the bundled dependencies.

Flow doesn't look for nested flow-typed directories though so you'd have to add it to your own libs.

@kasperpeulen
Copy link
Contributor Author

@thejameskyle Not sure if it is a good idea to hide the flow-typed definitions in react-scripts for the user. If you want to use flow, the user should get used some flow-typed folder anyway I guess?

The Flow team has plans for a flow-typed install command that will automatically install libdefs for all of your dependencies and stub the ones that do not have libdefs.

That is really nice. In that way you could add some hook to npm install so that they are always installed. I was wondering if I should add flow-typed to version control, but in that way, that would not be necessary anymore.

@jeffmo
Copy link

jeffmo commented Aug 16, 2016

That's not what I was talking about

Crash and burn! :)
Ok, yea if it's nested you're right -- would have to be present in the .flowconfig.

I was wondering if I should add flow-typed to version control

We definitely recommend adding the items that are installed by the command to version control since libdefs can be updated/improved over time. It wouldn't be very good if one person who flow-typed installs gets a newer/better version of the libdef than someone prior who thought there stuff typechecked, but actually there was a bug in the libdef.

The main thing flow-typed install will do is just go out and get all your libdefs for you after reading your package.json.

For create-react-app, I suspect we'd want node_modules/react-scripts/flow-typed/ (or whatever) to already have the baseline libdefs for you...so you'd only need to run flow-typed install for anything above and beyond those baseline dependencies.

@gaearon
Copy link
Contributor

gaearon commented Sep 30, 2016

It is not clear to me what we should do.
@jeffmo Is there anything actionable for our side in this issue?

@gaearon
Copy link
Contributor

gaearon commented Feb 11, 2017

Closing, but feel free to send a doc PR if you have suggestions about what should be there!

@gaearon gaearon closed this as completed Feb 11, 2017
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants