且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Flow类型声明中的省略号是做什么的?

更新时间:2023-01-18 20:09:15

这是Flow中的新语法,将来将指示该对象类型不精确(默认情况下常规注释将是精确对象)注释).

This is the new syntax in Flow, that in the future will be indicating, that this object type is inexact (when the regular annotation by default will be exact object annotation).

在一些发行版中,Flow将开始将{foo:number}视为一个确切的对象.为了表示不精确,必须在对象类型的末尾添加省略号:{foo:number,...}.这种新语法迫使开发人员选择不精确.

In a few releases, Flow will begin to treat {foo: number} as an exact object. To indicate inexactness, you must add an ellipsis to the end of an object type: {foo: number, ...}. This new syntax forces the developers to opt into inexactness.

在此处查看更多详细信息: https://medium.com/flow-type/on-the-roadmap-exact-objects-by-default-16b72933c5cf

See more details here: https://medium.com/flow-type/on-the-roadmap-exact-objects-by-default-16b72933c5cf