FlowTyped Declarations
See original GitHub issueIn usage with Flow, I get errors like this:
I am wondering that, since the values passed into condition
are negated to truthy or falsey, shouldn’t it accept any
type?
Apologies if this question belongs elsewhere. If so, please do direct me.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Declaration Files | Flow
In the first case, the exported types of a module are declared in a declaration file <FILENAME>.flow , that is located in the...
Read more >.flowconfig [declarations] | Flow
The [declarations] section in a .flowconfig file tells Flow to parse files ...
Read more >Type Annotations | Flow
Adding type annotations is an important part of your interaction with Flow. Flow has a powerful ability to infer the types of your...
Read more >Creating Library Definitions | Flow
Declaring A Global Type ... This tells Flow that any code within the project can reference the UserID global type – which, in...
Read more >Variable Types - JavaScript. Flow
When you are declaring a new variable, you may optionally declare its type. JavaScript has three ways of declaring local variables:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @AlexGilleran
I agree it is a matter of opinion if we should or not have an explicit boolean cast in conditions.
Except that I think, like @colshacol, that we should have a consistent behavior between
if (foo)
and<If condition={foo}>
.So, since Flow does not raise an error on
if
statement with non-boolean value, I think this link should not either.https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVUCuA7AxgFwEs5swo44AKADwC4wBnfAJ0OwHMBKep1jsAN6owYQlDA1Og4SLDMApvkzNS1ANwyAvjIVKVYAEQATeVACGmGPkYs27Axu1A
I agree @colshacol and @JalilArfaoui . Since it is so obvious that whatever passed into
<If condition={}>
will be treated as a boolean, like a normal if statement in JavaScript, I think it should be typed asany
.In my project we end up casting all statements with
Boolean()
like this:<If condition={Boolean(...)}>
, which I think is just noisy.