Do Flow types actually work?
See original GitHub issueI’ve been struggling getting Flow to type check my code, which heavily uses Preact, and as I was trying to introduce more types, I started running into more and more issues where I wasn’t able to type my components and HOCs. I dug a bit deeper into the subject and I believe that the types Preact package provides are simply wrong and aren’t used as expected.
I’ve set up a little example which shows what I mean: https://github.com/smirnowld/flow-preact-issues
It’s a simple component rendering another component that requires props. If I render that component without passing any props, Flow doesn’t detect any problems. At the same time, similar React example correctly errors out as Flow is able to resolve component types whereas I think Preact types are defaulted to any
(essentially skipping type checking altogether).
I’ve looked at TypeScript definitions for Preact and they seem to be much better than Flow libdefs. Has anyone had much luck getting their Preact components to be correctly typed and checked?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Seems like you’re hitting https://github.com/facebook/flow/issues/5469 and https://github.com/facebook/flow/issues/4657
Workarounds:
@jsx h
from your scripts, put it on a Babel config instead:flow-typed
next to.flowconfig
, and create a new file calledreact.js
:We removed support for flowtypes in
master
as they were somewhat broken and we don’t have experience with flow in the core team. On top of that we didn’t receive any PRs to fix those, so we made the decision to remove them.