Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

316
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda