What do the ellipsis do in Flow type declarations?

三世轮回 提交于 2021-02-05 05:37:27

问题


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

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

回答1:


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).

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.

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



来源:https://stackoverflow.com/questions/58227296/what-do-the-ellipsis-do-in-flow-type-declarations

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!