3 ms·
One aspect to consider before jumping into TS or Flow. As is the nature of any type system they rule out some programs that are perfectly fine. A workaround fo
by CuriousSkeptic 10y ago
One aspect to consider before jumping into TS or Flow. As is the nature of any type system they rule out some programs that are perfectly fine.
A workaround for this is to infer, or explicitly annotate, things to be dynamically typed. And/or helping the typer by casting to known types it failed to recognize. And it will work fine, after all this is precisely what you do with untyped ES (in your head).
This workaround was to strong of a code smell to just let things be like that though. So I've found myself spending time inventing ways to refactor code, or alter type definitions, to get proper typing instead. This can eat up time better spent implementing features.
Not everyone will have this problem, but if you're anything like me, do consider it before adopting these.
As a less intrusive option, consider using eslint with Babel and reference checking for modules. Not in any way a complete type-system, but might be just enough if you're allready comfortable with ES as it is.
- lobo_tuerto 10y agoDo you have a specific (and simple, if possible) example at hand?
- CuriousSkeptic 10y agoRedux perhaps. Spent some time inventing a way to pass event types to reducers. Turns out I reinvented redux-act in the end ;)