DEV Community

Discussion on: Do you use Static Typing in JavaScript?

 
nickytonline profile image
Nick Taylor

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.