Is there a way to type validation padding with possible types in a safe thread?

The following will throw an error null/undefined. The operand of an arithmetic operation must be a number.

as expected:

/* @flow */
function foo(x: ?number): number {
  return 1 - x;
}

      

try here

However, changing -

to +

will make it check:

/* @flow */
function foo(x: ?number): number {
  return 1 + x;
}

      

and everything is "excellent" try here

except that for input NaN

for null

or undefined

will be output.

Is there a way to print the validation padding with possible types in a safe thread? Or is it a bug like this ? (in which case I will happily write a bug report)

(edit: flow-typed@2.1.5 )

+3


source to share





All Articles