[英]Flow type. What is the difference between type {} & {||}
I dont know what is the exact differences.我不知道确切的区别是什么。
I want to know what is the differences我想知道有什么区别
According to doc https://flow.org/en/docs/types/objects/#toc-exact-object-types {||}
is a way to check for “exact” object types => no extra properties will be authorized with type with {||}
syntax根据文档https://flow.org/en/docs/types/objects/#toc-exact-object-types
{||}
是一种检查“精确” object 类型的方法 => 不会授权额外的属性带有{||}
语法的类型
sample from doc文件样本
// @flow
var foo: {| foo: string |} = { foo: "Hello", bar: "World!" }; // Error!
=> failed because foo can only have a foo property. => 失败,因为 foo 只能有一个 foo 属性。 Bar is unauthorized
酒吧未经授权
but if you do the following it will work但如果您执行以下操作,它将起作用
var foo: { foo: string } = { foo: "Hello", bar: "World!" }; // Work
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.