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

314
Views
Document optional destructured function parameter in JSDoc, with vscode type checking

The question Document destructured function parameter in JSDoc hints at this, but doesn't explicitly ask about the optional parameter in the question. And also, I don't think they're using VSCode type checking?

I'm getting this error when VSCode is type checking my JavaScript project for me:

(parameter) rejectMsg: string
Type '{}' is missing the following properties from type '{ rejectMsg: string; windowSize: number; stallLimit: number; }': rejectMsg, windowSize, stallLimit ts(2739)

The code in question is:

/**
 * Function that wraps the on 'data' callback of a Stream, and monitors for 'stalling'.
 *
 * @param {(data)=>void} [successCb] callback run on successful chunk of data
 * @param {{rejectMsg: string, windowSize: number, stallLimit: number}} [param1] options
 * @returns {(data)=>void}
 */
const stallGuard = (successCb = () => { }, { rejectMsg = 'Stalled', windowSize = 5, stallLimit = windowSize } = {}) => {
  // code goes here
}

If I don't put the default param for those options (= {}) then it barfs when I call without any options passed in.

Is there a way of satisfying the type checking for this?

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!