问题
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