简体   繁体   中英

Flow [signature-verification-failure] for curried async function

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.

you can try:

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

export onClickSubmit;

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();
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM