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

213
Visualizações
JSDoc - Types for multiple declarations, one after the other

I am currently using this:

    /** @type {TagsLevel} */
    export let list;
    /** @type {string} */
    export let tagListName;
    
    /** @type {string | null} */
    let srcTag = null;
    /** @type {number | null} */
    let srcTagNum = null;
    /** @type {number | null} */
    let srcLevelNum = null;

It's not very clear.

I wish I could use it that way:

    /** @type {TagsLevel} */
    /** @type {string} */
    export let list;
    export let tagListName;
    
    /** @type {string | null} */
    /** @type {number | null} */
    /** @type {number | null} */
    let srcTag = null;
    let srcTagNum = null;
    let srcLevelNum = null;

This should work identically to the previous code.

Is there a JSDoc syntax that enables something like this?

If not, I would like to know where to make the suggestion that support for such a case be introduced.

WHY THIS?

I am following the syntax of the function - @param. It's not identical, but it's very similar:

// Parameters may be declared in a variety of syntactic forms
/**
 * @param {string}  p1 - A string param.
 * @param {string=} p2 - An optional param (Google Closure syntax)
 * @param {string} [p3] - Another optional param (JSDoc syntax).
 * @param {string} [p4="test"] - An optional param with a default value
 * @returns {string} This is the result
 */
function stringsStringStrings(p1, p2, p3, p4) {
  // TODO
}

The alternative - this:


    /** @type {TagsLevel} */ export let list;
    /** @type {string} */    export let tagListName;
    
    /** @type {string | null} */ let srcTag = null;
    /** @type {number | null} */ let srcTagNum = null;
    /** @type {number | null} */ let srcLevelNum  = null;

But it's not very clear either, and it makes the line very long.

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