question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FlowTyped Declarations

See original GitHub issue

In usage with Flow, I get errors like this:

screen shot 2018-01-09 at 12 14 30 am

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:open
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JalilArfaouicommented, Apr 4, 2018

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

0reactions
draperunnercommented, Jun 15, 2018

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 as any.

In my project we end up casting all statements with Boolean() like this: <If condition={Boolean(...)}>, which I think is just noisy.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found