Recoil is written in Flow, but it's published without the types so the information is lost. Would be great if Flow types were published with the library.
@mondaychen Do you know how we would do this?
A neat trick is publishing the src directory to npm and putting a file like this at dist/index.flow.js:
// @flow
export * from '../src/index.js`;
Flow should pick that up and use the source directly.
PS: Relay had this problem for years and they have been working on it recently. They might have some clues.
Thanks @AlicanC for bringing this up! I'll chat with someone in Relay team about it.
Looks like we need to generate a .js.flow file in dist. Relay is using gulp so I guess we'll need to find something that works with rollup.
Is there any news on this. Using v0.0.10 and still not shipped with flow types.
If there aren't plans to add this, happy to work on a PR to ship as part of flow-typed like what styled-components do?
@aaronabramov or @mondaychen - Can @Brianzchen help with this?
unless we figure out the way to generate types automatically flow-typed might be a good way to do it as well
Adding it through flow-typed means to manually build and maintain a flow type file, correct?
Ideally we should do it in an automatically way since this project already has typing information.
I'm thinking maybe we are able to add flow support by using https://github.com/lessmess-dev/gen-flow-files
Definitely agree if we want to ship types, doing within the project is more desirable.
https://github.com/lessmess-dev/gen-flow-files is one option though looks like they don't have any other options besides input/output dir which means tests will be parsed too.
The other option is https://github.com/Macil/flow-copy-source which simply dumps source code back into dist with all files appended with .flow. Looks like graphql use this method and they support more ignore options
Con here is if you care about the unpacked size it will larger because you're shipping all your src code
If --ignore option is the only concern, I think it will be easy to add that feature to gen-flow-files too.
Most helpful comment
Thanks @AlicanC for bringing this up! I'll chat with someone in Relay team about it.
Looks like we need to generate a
.js.flowfile in dist. Relay is using gulp so I guess we'll need to find something that works with rollup.