When we instantiate a model, it's critical to make sure not to use properties that are not part of the model type, especially because it can be the result of a typo.
For example, given the definition:
export type BarModelType = {
barStr: string,
barNum: number,
};
This should yield an error:
const bar = Bar.fromJS({ barstr: "blah" })
because barstr !== barStr.
It's not clear whether the library is supposed to allow Flow to detect these errors.
Currently, sometimes it does not, and sometimes is does but it seems to be a side effect of the use of $Shape<> in some condition (when default properties are defined).
I'm not 100% sure about this, but I think this requirement (no extra properties) could be precisely enforced by prepending $Shape<BarModelType> & ... to the json parameter of the fromJS(). method.
When we instantiate a model, it's critical to make sure not to use properties that are not part of the model type, especially because it can be the result of a typo.
For example, given the definition:
This should yield an error:
because
barstr!==barStr.It's not clear whether the library is supposed to allow Flow to detect these errors.
Currently, sometimes it does not, and sometimes is does but it seems to be a side effect of the use of
$Shape<>in some condition (when default properties are defined).I'm not 100% sure about this, but I think this requirement (no extra properties) could be precisely enforced by prepending
$Shape<BarModelType> & ...to thejsonparameter of thefromJS(). method.