You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* @flow */typeManyFoobar={foobar: {values: Array<string>}};typeOneFoobar={foobar: {value: string}};// Uses the logic of manyFoobarMethod by// placing its single argument into an arrayfunctiononeFoobarMethod(param: OneFoobar){constparamForMany={
...param,foobar: {values: [param.foobar.value]}};returnmanyFoobarMethod(paramForMany);}functionmanyFoobarMethod(param: ManyFoobar){returnparam.foobar.values.length;}oneFoobarMethod({foobar: {value: "test"}});manyFoobarMethod({foobar: {values: ["test"]}});
triggers this error:
4: foobar: {
^ property `values`. Property not found in
10: foobar: {
^ object type
The text was updated successfully, but these errors were encountered:
@agentcooper it seems indeed that while your technique yields the same result, flow is inferring the value correctly and does not error out. Hopefully this gives more insight about the bug.
typehorror
changed the title
Flow ignores attribute assigned with the spread operator (example included)
Flow ignores attribute overwritten with the spread operator (example included)
May 28, 2017
It seems that when the spread operator is being used to extend a value, flow somewhat can't identify the presence of a sub-attribute.
Problem is reproduced here on the flow try page
triggers this error:
The text was updated successfully, but these errors were encountered: