Flow类型声明中的省略号是做什么的? [英] What do the ellipsis do in Flow type declarations?

查看:73
本文介绍了Flow类型声明中的省略号是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下Flow代码中的省略号是什么,它们做什么?

What are the ellipsis called in the following Flow code and what do they do?

export type ListTypeNode = {
  +kind: 'ListType',
  +loc?: Location,
  +type: TypeNode,
  ...
};

推荐答案

这是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

这篇关于Flow类型声明中的省略号是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆