When defining a model type with a property of another model type like this:
export type MyModelType {
field: OtherModelType,
};
the fromJS function for MyModelType calls the fromJS from the Other model class. However, if field is defined as a maybe type (e.g. field: ?OtherModelType), the codemod doesn't recognize it as a model type or do anything in the fromJS function.
The correct behavior would be to still have the fromJS function contain code like the following, taking the null/undefined case into account:
state.field = state.field == null ? state.field : Other.fromJS(state.field);
When defining a model type with a property of another model type like this:
the
fromJSfunction forMyModelTypecalls thefromJSfrom theOthermodel class. However, iffieldis defined as a maybe type (e.g.field: ?OtherModelType), the codemod doesn't recognize it as a model type or do anything in thefromJSfunction.The correct behavior would be to still have the
fromJSfunction contain code like the following, taking the null/undefined case into account: