简体   繁体   English

*和*流量之间有什么区别?

[英]what is the difference between any and * in flow?

I have read flowtype documentation and I cannot be sure about. 我已经阅读了流程类型文档,但我不确定。

Is there any difference between the two? 两者之间有什么区别吗?

* tells Flow to infer a type parameter. *告诉Flow推断类型参数。 To my knowledge, it can only be used for type parameters (eg Array<*> ). 据我所知,它只能用于类型参数(例如Array<*> )。 It will always either infer a valid type for that position, or give you an error. 它总是会推断该职位的有效类型,或者给您一个错误。

However, any is an unsafe type. 但是, any类型都不安全。 It can be used to circumvent the typechecker. 它可以用来规避类型检查器。 You can assign anything to a variable typed as any , and you can also assign it to anything. 您可以将任何东西分配给类型为any的变量,也可以将其分配给任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM