Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

317
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda