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

263
Views
How to type a function with parameters in typescript?

I have these interfaces and functions to manipulate data (email, password and, name) to send to my API.

interface SignUpData {
        email: string
        password: string
        name: string
    }

interface SignupProps {
    handleSignup: () => void
    errors: DeepMap<FieldValues, FieldError>
    register: UseFormRegister<FieldValues>

}

const handleSignup = ({ name, email, password }: SignUpData) => {
        api
        .post("/users", {name, email, password})
}

<SignupForm
                 
                errors={errors}
                register={register}
                handleSignup={handleSubmit(handleSignup)}
            />

However, I am getting a problem in my last line

handleSignup={handleSubmit(handleSignup)}

HandleSubmit is default of forms

It happens because:

Argument of type '({ name, email, password }: SignUpData) => void' is not assignable to parameter of type 'SubmitHandler'. Parameter types '__0' and 'data' are incompatible. The type '{ [x: string]: any; }' does not have the following properties of type 'SignUpData': email, password, namets(2345)

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!