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

First class Flow support #9

Open
vovacodes opened this issue Jul 22, 2018 · 1 comment
Open

First class Flow support #9

vovacodes opened this issue Jul 22, 2018 · 1 comment

Comments

@vovacodes
Copy link
Contributor

This is an RFC, what do you think if we use flow for the whole react-recomponent codebase including tests? This would eliminate the need for maintaining the flow types separately from the actual implementation and make sure the types are always correct.
I believe that having the react-recomponent code type-checked should also simplify the maintenance a bit by adding extra level of safety besides tests.

Using flow in tests will make sure we test against the correct API.

On the downsides, it could be more difficult for some people to contribute if they don't have any experience working with flow before.

Anyways, what is you stance on it?

@philipp-spiess
Copy link
Owner

I remember doing exactly that in the beginning but as you said the tests are getting very obscure with errors like this that we would need to handle:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ __tests__/ReComponentImmutable-test.js:21:30

Cannot call document.documentElement.appendChild because property appendChild is missing in null [1].

     __tests__/ReComponentImmutable-test.js
      18│   let container;
      19│   beforeEach(() => {
      20│     container = document.createElement("div");
      21│     document.documentElement.appendChild(container);
      22│   });
      23│
      24│   const State = Record({ count: 0 });

     /private/tmp/flow/flowlib_25a59207/dom.js
 [1] 658│   documentElement: HTMLElement | null;

And since ReComponent works by making use of meta-programming, I'm also not sure if Flow can even be used in the sources.

I think my two biggest worries with this is that:

  1. It makes the tests and sources harder to read for someone who's not familiar with Flow
  2. I'm not sure if this will make it harder to build TypeScript definitions.

The Flow integration right now is inspired by what's happening in the Immutable.js repo. That's why we have the separate Flow tests. That approach likely also works with TypeScript.

philipp-spiess added a commit that referenced this issue Jul 22, 2018
This is a leftover from a time when I tried to run all tests with Flow
as well. Check out #9 for arguments why this is not done right now.
philipp-spiess added a commit that referenced this issue Jul 22, 2018
This is a leftover from a time when I tried to run all tests with Flow
as well. Check out #9 for arguments why this is not done right now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants