Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Also, you can progressively opt in to add typing information, while still getting most of the benefits without.


The same can be done with TypeScript. Type inference has been added to it in 2015.


Awesome, did not know this.


TypeScript type inference is minimal though and doesn't go very far. It falls back to "any" very quickly (and if you use the noImplicitAny option, then you have to type almost everything).

It does a decent enough job at return types, but not a whole lot beyond that.


Do you have a use case where something would be correctly inferred in Flow but not in TS?


The classic example is:

  function double(x) {
    return x * 2;
  }
  const result = double("foo");
Which passes in TS, but fails in Flow. In TS, the 'x' parameter to the double function is inferred as Any.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: