re: Do you use Static Typing in JavaScript? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: The way that I interpreted this example from their homepage is that the type checker is assuming that n should be a Number since the function uses ...

Maybe it's not clear on their site., The function definition takes precedence like you thought it should.

Here's the example on their site:

// @flow
function square(n: number): number {
  return n * n;
}

square("2"); // Error!

What they're showing here is that the type checker won't allow you to call the function with a string.

code of conduct - report abuse