流类型,`+`符号在属性前面是什么意思?
问题描述:
我遇到了以下用js FlowType编写的代码(我有兴趣知道在FlowType的上下文中+的值不是普通的JS)。
I came across the following code written in js FlowType (I am interested to know the value of + in the context of FlowType not in general JS).
可能您可以解释一下 +
符号在下面的代码中在该属性前面的含义:
Could you please explain me what does the +
symbol mean in front of the property in the code below:
export type User = {
+name: string,
+surname: string,
+personId: PourceId,
}
我在文档中找不到任何参考,也欢迎任何链接。
I could not find any reference in the documentation, any link is also welcome.
答
物业前面的 +
符号表示该物业是只读
The +
symbol in front of the property means the property is read-only
参考: https://flow.org/en/docs/types/interfaces/#toc-interface-property-variance-read-仅限只写