Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

322
Views
Propagating type definitions on child components

I have a component defined as follows:

// Form.Container.tsx

export default function MyForm(props: IFormProps): JSX.Element {
  /*
    some crazy logic here
  */
  return (
    <Form<{initialValues: RFFFormProps['initialValues'] }> initialValues={{ name: 'John Doe' }}>
      <FormField type="text" name="name" />
      {/* more FormField components here */}
    </Form>

  )
}

I'm fairly new with Typescript but I've been able to get a hold on the concepts since I have some background on C#. I am trying to propagate the types through the child components. What I mean is that I want to be able to make FormField props values to be enforced depending on what Form.initialValues prop receives. For example, I want FormField.name to only accept the key values that Form.initialValues receives (in this case, name can only receive a value of "name" since it's the only key in initialValues). Is there a way to do that or is it something that Typescript doesn't allow?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!