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

169
Views
Handle void method as object's property in React, redux, typescript

Below are the details. I am a little confuse on how to test my file with an object with function that return void.

type Pros={
 studentid: StudentId
 pageId?: PageID
closeForm: () =>void }

for unit test how should I do

const testPros={
studentid:"123"
padeId:"123"
closeForm:null //I am confuse here }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use a function that doesn't have implicit return nor has the return keyword anywhere. (Don't use return; or return undefined;.) You should also use pageId, not padeId, and each key-value pair should be separated with a comma.

const testPros = {
  studentid:"123",
  pageId:"123",
  closeForm() {
  }
};
about 4 years ago · Juan Pablo Isaza Report

0

You can do something like this.

const testPros= {
  studentid: "123",
  pageId: "123",
  closeForm: () => {},
}

the type () => void means the closeForm accepts a function that has no parameters and does not have a return value.

You could also have a function like:

const closeFormHandler = () => {
  // Do something here without a return statement
}

const testPros= {
  studentid: "123",
  pageId: "123",
  closeForm: closeFormHandler,
}

about 4 years ago · Juan Pablo Isaza Report
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!