I need to reset some Object values and I decided to use a forEach loop. This Object values are defined as it follows:
Basically, I've declared this Object type. It's important the Object contains at least 2 attributes with different types. For example, a number and a string:
type FooType = {|
a: number,
b: string
|}
And I have written an Object of the same type that will be used to set/reset the initial values in another one of the same type.
Hi,
This might be a silly question but...
I need to reset some Object values and I decided to use a
forEach
loop. This Object values are defined as it follows:Basically, I've declared this Object type. It's important the Object contains at least 2 attributes with different types. For example, a
number
and astring
:And I have written an Object of the same type that will be used to set/reset the initial values in another one of the same type.
Therefore, when I use the
Array.forEach
for an assignment I get the following flow error:I guess that Flow is not able to detect that the key used to read from
INITIAL_FOO
and the key used to write infoo
are the same on every loop.Is there any way to fix this and keep the
forEach
loop?Here is a link to test this example: https://flow.org/try
Thanks,