Unable to resolve flow annotation error when using immutablejs records and calling update on one

Viewed 494

I see the following record type code:

type AppProps = {
  +fetches: Map<string, number>,
};
export const makeApp: RecordFactory<AppProps> = Immutable.Record({
  fetches: Immutable.Map()
});
export type App = RecordOf<AppProps>;

Now I have a call that uses the record's update function:

const state = makeApp({});
const result = state.update('fetches', val =>
    val.set(action.meta.actionBase, 1)
  );

All unit tests pass, behaviour is good, but I get a flow error:

Error:(40, 18) Missing type annotation for T. T is a type parameter declared in RecordInstance [1] and was implicitly instantiated at call of method update [2].

I have an idea what is going on here, but I don't know flow well known to actually fix this, or even come up with a workaround. Please help!

ImmutableJS version "immutable": "^4.0.0-rc.12",

1 Answers

Flow is asking for a concrete type argument for T, which is defined in the update function of state.

Here's another example of a cause and fix of this error message: Missing annotation error Fixed

If you provide the type signature of state.update, I may be able to provide more information.

Related