score:0

ok, i seem to have figured out a fix:

by creating a

type promptinputcustominput<t> = (value: t, onchange: (newvalue: t) => void) => react.reactnode;  

and changing the interface to:

interface promptinput {
  key: string,
  title: string,
  custominput?: promptinputcustominput<any>;
}

and changing where i pass the arguments to:

<inputpromptdialog
  inputs={[
    { key: 'fullname', title: 'full name' },
    { key: 'email', title: 'email' },
    { key: 'role', title: 'role', custominput: ((value, onchange) => <roleselector onchange={(selectedroleid: string) => onchange(selectedroleid)} />) as promptinputcustominput<string> },
  ]}
/>

this creates the desired result i am looking for. but i would still be interested to know if there is a way of doing this without having to always cast the values i am passing as promptinputcustominput<desired_type>


Related Query

More Query from same tag