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

Flow support #165

Closed
AlicanC opened this issue May 25, 2020 · 9 comments
Closed

Flow support #165

AlicanC opened this issue May 25, 2020 · 9 comments

Comments

@AlicanC
Copy link

AlicanC commented May 25, 2020

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.

@davidmccabe
Copy link
Contributor

@mondaychen Do you know how we would do this?

@AlicanC
Copy link
Author

AlicanC commented May 27, 2020

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.

@mondaychen
Copy link
Contributor

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.

@Brianzchen
Copy link
Contributor

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?

@drarmstr
Copy link
Contributor

drarmstr commented Jul 7, 2020

@aaronabramov or @mondaychen - Can @Brianzchen help with this?

@aaronabramov
Copy link
Contributor

unless we figure out the way to generate types automatically flow-typed might be a good way to do it as well

@mondaychen
Copy link
Contributor

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

@Brianzchen
Copy link
Contributor

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

@mondaychen
Copy link
Contributor

If --ignore option is the only concern, I think it will be easy to add that feature to gen-flow-files too.

AlexGuz23 pushed a commit to AlexGuz23/Recoil that referenced this issue Nov 3, 2022
Summary:
Fixes facebookexperimental/Recoil#165
Use https://github.com/lessmess-dev/gen-flow-files to generate flow type definitions for consuming applications

This generates tons of flow errors that can't be resolved though so users have to add the dependency to their `[declarations]`

```
[declarations]
.*node_modules/recoil/.*
```

Otherwise you get errors such as:
<img width="908" alt="Screen Shot 2020-07-11 at 7 47 03 pm" src="https://user-images.githubusercontent.com/12436524/87221437-53bfe700-c3af-11ea-9ab5-31a1c7c82d40.png">

Pull Request resolved: facebookexperimental/Recoil#468

Reviewed By: drarmstr

Differential Revision: D23144185

Pulled By: mondaychen

fbshipit-source-id: 7359ac1e75b29cfa24ef516f1a3d7ed0221d3a29
snipershooter0701 pushed a commit to snipershooter0701/Recoil that referenced this issue Mar 5, 2023
Summary:
Fixes facebookexperimental/Recoil#165
Use https://github.com/lessmess-dev/gen-flow-files to generate flow type definitions for consuming applications

This generates tons of flow errors that can't be resolved though so users have to add the dependency to their `[declarations]`

```
[declarations]
.*node_modules/recoil/.*
```

Otherwise you get errors such as:
<img width="908" alt="Screen Shot 2020-07-11 at 7 47 03 pm" src="https://user-images.githubusercontent.com/12436524/87221437-53bfe700-c3af-11ea-9ab5-31a1c7c82d40.png">

Pull Request resolved: facebookexperimental/Recoil#468

Reviewed By: drarmstr

Differential Revision: D23144185

Pulled By: mondaychen

fbshipit-source-id: 7359ac1e75b29cfa24ef516f1a3d7ed0221d3a29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants