0

It is javascript code

 const handleChange = ({ target: { name, value } }) => formDispatch({ name, value });

I tried to convert this code to TypeScript

const handleChange = ({ (target:any): { (name:string), (value:string) } }) => formDispatch({ name, value });

but VS Code doesn't interpret this. what is wrong?

  • `target:any` is not valid TypeScript code for annotating types of destructured parameters. – VLAZ May 12 '21 at 05:42

1 Answers1

0

You may want something like:

 const handleChange = (target: { name: string, value: any }) => formDispatch(target);

Or a bit different, depending on what formDispatch is expecting

Aadmaa
  • 829
  • 5
  • 13