score:0

use generics

 function handlechange<t extends htmlelement>(key: keyof formstate) {
    // e: any could work here but i would like to avoid that if possible
    return (e: react.changeevent<t>) =>
      setfields((fields) => ({ ...fields, [key]: e.target.value }));
  }

Related Query

More Query from same tag