gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.
3.51k stars 59 forks source link

question: inherit return type of type property #105

Closed thereis closed 1 year ago

thereis commented 1 year ago

Hello, is it possible to inherit the return type dynamically of a given property? For example, let's assume we have a React component:

type InputProps = {
  value: string
}

export const Input: FC<InputProps> = () => (<></>);

And then, we have the following type:

type FormField = {
  component: Component | ForwardRefExoticComponent<any> | any;
  props: ??? // it should get the return 
 }

const fields: FormField[] = [
  {
      component: Input,
      props: { value: "test" }
  }
]

I've been trying this from the past few hours and couldn't achieve any valuable results.

Best.

ecyrbe commented 1 year ago

This is not an issue with hotscript.

please seek help in typescript dedicated discords for typescript related help.