What do the ellipsis do in Flow type declarations?

Viewed 780

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 Answers

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

Related