Try out Facebook’s Flow typechecker online

You can now try out Flow [1], Facebook’s typechecker for JavaScript, online, at tryflow.org.




The following example demonstrates Flow‘s power:



function mul(x,y) {
return x * y;
}
mul('a', 'b'); // static error

The last line produces a static (“compile time”) error, because Flow infers the signature:



function mul(x : number, y : number) : number

In contrast, TypeScript infers the following signature (which you can check in the TypeScript Playground):



function mul(x : any, y : any) : number

Further reading:



  1. Statically typed JavaScript via Microsoft TypeScript, Facebook Flow and Google AtScript


Comments

Popular posts from this blog

Steve Lopez and the Importance of Newspapers

A Treasure Hunt Without The Treasure

Drop a ping-pong ball in the clown’s mouth