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 })
I don't know what does it mean circle: (null : ?{ setNativeProps(props: Object): void })
谢谢您的建议.
推荐答案
It's flow's typecasts, you can see more details in this post
类型转换对于检查假设和帮助Flow推断您想要的类型特别有用.以下是一些示例:
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
属性是可为空的对象,该对象具有setNativeProps
方法,默认值为null
.
so circle: (null : ?{ setNativeProps(props: Object): void })
is mean circle
property is a nullable object which have a setNativeProps
method and default value is null
.
这篇关于Javascript语法为null:?{}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!