Home > Mobile >  Flow `[signature-verification-failure]` for curried async function
Flow `[signature-verification-failure]` for curried async function

Time:11-25

I have received the following error:

type Submit = {
  form: any,
  handleSubmit: FunctionType<any, any>,
  ...
}
Flow-IDE

Submit: type Submit = {
    form: any,
    handleSubmit: FunctionType < any,
    any > ,
    ...
}
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return:Flow(signature-verification-failure)
Cannot build a typed interface for this module. You should annotate the exports of this module with types. Missing type annotation at function return: [signature-verification-failure] (index.js:31:11)flow

I have this function

type Submit = {
  form: Object,
  handleSubmit: FunctionType<Object, any> // this is our custom type, works fine
};

export const onClickSubmit = ({
  form,
  handleSubmit
}: Submit) => async (input: Object): Promise<any> => {
  await handleSubmit(input);
  form.reset();
};

The area highlighted is }: Submit) on the ).

I am at a loss what it wants me to do, adding any type definition after ): doesn't help at all.

The example in the type-first flow docs is providing examples that are not helpful. I cannot export functionName with special definition only for it like in their module.exports examples.

CodePudding user response:

you can try:

const onClickSubmit = ({
  form,
  handleSubmit
}: Submit) => async (input: Object): Promise<any> => {
  await handleSubmit(input);
  form.reset();
};

export onClickSubmit;

CodePudding user response:

It was simpler than I expected, figured it out right after posting

type Submit = {
  form: Object,
  handleSubmit: FunctionType<Object, any>
};

const onClickSubmit = ({
  form,
  handleSubmit
}: Submit): FunctionType<Object, any> => async (input: Object): Promise<any> => {
  await handleSubmit(input);
  form.reset();
};
  • Related