Javascript 语法 null : ?{}

Javascript syntax null : ?{}

例子 https://github.com/facebook/react-native/blob/master/Examples/UIExplorer/PanResponderExample.js#L41

var PanResponderExample = React.createClass({
  ...
  circle: (null : ?{ setNativeProps(props: Object): void })
  ...

不知道什么意思circle: (null : ?{ setNativeProps(props: Object): void })

感谢任何建议。

flow's typecasts, you can see more details in this post

Typecasts are particularly useful to check assumptions and help Flow infer the types you intend. Here are some examples:

  (x: number) // Make Flow check that x is a number
  (0: ?number) // Tells Flow that this expression is actually nullable.
  (null: ?number) // Tells Flow that this expression is a nullable number.

所以 circle: (null : ?{ setNativeProps(props: Object): void }) 是意思 circle 属性 是一个可以为 null 的对象,它有一个 setNativeProps 方法,默认值是 null.