This doesn't compile on the "Try Flow":
/* @flow */
type A = { a: number, b: string};
type B = { a: string, b: string };
const x: A = { a:1, b:'2' };
const y: B = { ...x, a: x.a.toString() }
Error is:
const y: B = { ...x, a: x.a.toString() }
^ Cannot assign object literal to `y` because number [1] is incompatible with string [2] in property `a`.
References:
3: type A = { a: number, b: string};
^ [1]
4: type B = { a: string, b: string };
^ [2]
Note that this code works in TypeScript (when I remove field override it fails to compile as it is supposed to).
How to achieve same behavior in Flow without enumerating all fields of original object?