Flow version: 0.78.0 / 0.86.0
Expected behavior
Flow understands static defaultProps and optional properties properly
Actual behavior
Flow does not respect default properties defined with static defaultProps
Example:
Assuming I have the properties defined as following:
type Props = {
/**
* A Function. Invoked on load error with {nativeEvent: {error}}.
*/
onError?: (Error) => void,
/**
* A Function. Invoked when load completes successfully.
*/
onLoad?: () => void,
....
And have
static defaultProps = {
onError: () => {},
onLoad: () => {},
...
};
Trying to use them lead to flow error:
onError: (event: any) => void;
onError(event: any) {
const { nativeEvent } = event || {};
this.props.onError(nativeEvent || new Error('unknown error'));
}

Workarounds
Workarounds like making the properties required are not acceptable because:
- It leads to confusion in documentation
- It leads to ESLINT error

Flow version: 0.78.0 / 0.86.0
Expected behavior
Flow understands
static defaultPropsand optional properties properlyActual behavior
Flow does not respect default properties defined with
static defaultPropsExample:
Assuming I have the properties defined as following:
And have
Trying to use them lead to flow error:
Workarounds
Workarounds like making the properties required are not acceptable because: