I have a case in one of my reducers which is using merge from immutable Map:
case ADD_QUESTION: {
const { question }: { question:Question} = action.payload;
const questionMap: QuestionMap = ((fromJS(question): any): QuestionMap);
return state.merge({ [question.id]: questionMap });
}
All is working, and unit tests are fulfilled, however flow complains about something:
Missing type annotation forK.Kis a type parameter declared inMap[1] and was implicitly instantiated at call of methodmerge[2]. (questions.js:22:14)flow
Missing type annotation forK_.K_is a type parameter declared in function type [1] and was implicitly instantiated at call of methodmerge[2].
I can't figure out how to fix it:
I am getting a similar error whe using mergeIn and updateIn too:
case ADD_USER_TO_QUESTION_VOTES: {
const { payload }: { payload:AddUserToQuestionVotesPayload } = action;
const { authedUserId, questionId, optionKey } = payload;
return state.mergeIn(
[questionId, optionKey, 'votes'],
authedUserId,
);
}
Missing type annotation forK.Kis a type parameter declared inMap[1] and was implicitly instantiated at call of methodmergeIn[2]. (questions.js:28:14)flow
Missing type annotation forV.Vis a type parameter declared inMap[1] and was implicitly instantiated at call of methodmergeIn[2]. (questions.js:28:14)
Answered on SO. Flow is asking you to specify an explicit type argument. Here's a simpler example:
Missing annotation error
Fixed