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
types flowtype


source to share


No one has answered this question yet

Check out similar questions:

1093
What is the canonical way of type checking in Python?
677
How do I check if a type is a variable string?
2
Optional prop function in React component. Error checking stream type.
1
Stateless Reagent Flow Type Initiatives
1
Stream Iterable type
1
Refining types in a stream
1
thread error while accessing function expression of type defined after truth check
0
FlowType: Conditional type checking, possibly Misbehavior when assigning a non-primitive value
0
Stream: accept multiple types as function arguments
0
Disable Can be checking stream type



All Articles
Loading...
X
Show
Funny
Dev
Pics