In other words, what are the benefits of using a type system like Flow/TS?
I would recommend listening to this podcast from the creator of the TypeScript compiler. It goes into detail the reasons why TypeScript was invented and what problems it tries to solve with JavaScript.
Daniel V
Runnin around in front-end code and having a blast!
TS and Flow has their own ecosystem, their use can provide you with several benefits over vanilla JS. The Type System is only one of those things.
Generally speaking, it's always a good idea to catch potential sources of bugs as early as possible, way before the application would get ran.
The weak type system and the mutable nature of JavaScript provides many opportunities for an application to misbehave at runtime and makes it very difficult to analyze it without running it.
One advantage of the a stronger type system, like that of TS's or Dart's (I do not know Flow) is that types are optionally present or can be inferred. That helps static analysis tools to understand the codebase without running it and provide the programmer with useful information on potential pitfalls, sources of bugs.
Maintenance Working on a large codebase, being able to analyze the code makes it simpler to track your code, navigate it, find uses of variables, classes or other data structures. Most IDEs also provide refactoring tools on top of that.