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 typing is incorrectly exported #3247

Closed
ghost opened this issue Jul 26, 2017 · 7 comments
Closed

Flow typing is incorrectly exported #3247

ghost opened this issue Jul 26, 2017 · 7 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 26, 2017

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

  • The Field and FieldArray exports on index.js.flow have FieldProps and FieldArrayProps respectively as their props. These props are for the component passes to Field or FieldArray, not for Field and FieldArray themselves.
  • The build:flow does not export the flow definitions to the es folder
  • The Dispatch in FieldProps.types.js.flow should have a wildcard generic type (Dispatch<*>) or else flow complains about ambiguous polymorphic type.

What is the expected behavior?

  • The Props for Field and FieldArray in index.js.flow should be FieldInputProps and FieldArrayInputProps instead.
  • build:flow should also export the flow definitions to the es folder
  • Change Dispatch to Dispatch<*> in FieldProps.types.js

Sandbox Link

What's your environment?

redux-form@7.0.2

Other information

@ghost ghost mentioned this issue Jul 26, 2017
@gabrielhpugliese
Copy link

I added .*/node_modules/redux-form/.*\.flow to section [ignore] inside .flowconfig in the meantime.

@erikras
Copy link
Member

erikras commented Jul 26, 2017

Fantastic reporting, @huangbi! 👍 👍

@erikras
Copy link
Member

erikras commented Jul 26, 2017

Published in v7.0.3.

@ravicious
Copy link

The Dispatch in FieldProps.types.js.flow should have a wildcard generic type (Dispatch<*>) or else flow complains about ambiguous polymorphic type.

Correct me if I'm wrong, but I believe that * is not "a wildcard generic type". It's an existential type.

An existential type is used as a placeholder to tell Flow to infer the type.

I saw a weird cases in my apps where having * in the type would use a different type depending on the order of calling the function with different arguments.

I believe a wildcard generic type looks like this in Flow:

function identity<T>(value: T): T {
  return value;
}

I just wanted to point it out there, because from my experience, a liberal use of * resulted in many weird Flow errors down the road which I've been fixing with the generic type.

@erikras
Copy link
Member

erikras commented Aug 4, 2017

@ravicious So what should it be? Dispatch<any> or just Dispatch with no type?

@ravicious
Copy link

I'm not really an expert on this, so I'm afraid I can't tell you what should be there. :(

I just wanted to point out that this could be a good point to start debugging if people ever come with a problem about Dispatch type.

@lock
Copy link

lock bot commented Aug 7, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants