We have a pure component, and we are trying to convert this to the Flow type safety. The application is using this component as a HOC ( High-Order Component). It is generating a context and injecting to the dispatched components.
Therefore, one method of the HOC is returning an object literal which is involving many binding operations. In this key-value pairs, there is one expression we didn't handle.
We are getting an error about missing notation:
Missing type annotation for T. T is a type parameter declared in array type [1] and was implicitly instantiated at call of method filter [2].
export type PropsType = {
reviewConf ? : Object,
...
}
export type ContextType = {
registerComponent: () => void,
errors ? : Array < any >
...
}
export type StateType = {
meta: Object
}
class AbstractPureFormComponent extends React.PureComponent < PropsType, StateType > {
constructor(props: PropsType, context: ContextType) {
super(props, context)
this.state = {
meta: {}
}
}
getChildContext() {
return {
registerComponent: this.registerComponent.bind(this),
...
errors: Object.keys(this.state.meta).filter(
name => this.state && this.state.meta[name].error
)
}
}
}
}
So what is the best practice for typing this error:
key? Should it be an interface or type or something else...