3 ms·
My point is mostly that you can get away with explicitly typing less things in flow and still get similar levels of coverage. For example, consider this example
by lhorie 8y ago
My point is mostly that you can get away with explicitly typing less things in flow and still get similar levels of coverage. For example, consider this example:
export function formatTime(time: Date) {
return digitize(time.getHours()) + ':' + digitize(time.getMinutes());
}
function digitize(n) {
return ('0' + n.toStirng()).substring(-2);
}
Just a single type declaration is enough to let Flow catch the typo here. In TS, you'd also have to write the argument types for `digitize`. Importantly, if you wanted to explicitly add arg types for `digitize` w/ Flow, your editor can tell you what they are supposed to be.
- z3t4 8y agoFLow seem to be better at inferring types. example: function foo(n) { return n*2; } foo("bar");