I'm trying to implement flow into my React application. So far it worked fine, but i'm having trouble with a default value.
The function header is:
const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
The type alias for TFormControls is:
type TFormControls = {
onSubmit?: boolean,
onReset?: boolean,
onClear?: boolean
}
I would expect, since I put a maybe operator in there controls: ?TFormControls, that it would either be my type-alias or null/undefined, but flow tells me:
src/components/forms/FormControls.jsx:35
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ null. This type is incompatible with
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ object type
src/components/forms/FormControls.jsx:35
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ object type. This type is incompatible with
35: const FormControls = ({ form, controls = null, labels = {} }: { form: any, controls: ?TFormControls, labels?: TFormControlLabels}) => (
^^^^^^^^ null
Any pointers would be most welcome!
Edit: As requested, the full function with error as an example