Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the ellipsis do in Flow type declarations?

Tags:

flowtype

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

export type ListTypeNode = {
  +kind: 'ListType',
  +loc?: Location,
  +type: TypeNode,
  ...
};
like image 608
Bashar Avatar asked Mar 03 '23 08:03

Bashar


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

like image 165
frontendgirl Avatar answered Apr 01 '23 20:04

frontendgirl