4 ms·
What do you mean it's not possible to work around libraries and APIs returning nulls? That's exactly the point I made, Flow solved it. Yes, they had to write i
by k_bx 12y ago
What do you mean it's not possible to work around libraries and APIs returning nulls? That's exactly the point I made, Flow solved it.
Yes, they had to write interface for all browser APIs (and it's incomplete, PRs welcome), and in places where API might return null it states that it may return it. And your code has to deal with null and non-null cases explicitly (or at least put an if).
You are right though that this type-system is much weaker than other languages like Elm or Haskell, and for me, being from a Haskell world, writing JS with Flow was still a disappointment. It's just that currently there's no better alternative I know in terms of interop with JS and good level of error-reporting.
- the_gipsy 12y ago> What do you mean it's not possible to work around libraries and APIs returning nulls? That's exactly the point I made, Flow solved it. Sorry, I had the really stupid misconception that Maybe Types could not be applied to libraries and browser APIs. So it seems like a good start, but it doesn't seem really useful if they aren't even in the basic API's descriptions: https://github.com/facebook/flow/blob/master/lib/dom.js#L198 https://github.com/facebook/flow/blob/master/lib/dom.js#L198
- k_bx 12y agoIf something might return null -- feel free to make a PR with making it a Maybe type, like here: https://github.com/facebook/flow/blob/master/lib/dom.js#L359 https://github.com/facebook/flow/blob/master/lib/dom.js#L359