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

276
Visualizações
How to define properties of an object returned by a function

I'm working on Gscript.

function globales() {
  var data = {
    dir: DriveApp.getFolderById('id'),
    sinky: "test",
    numberino : 42
  };
  return data;
}


function test()
{
  var rep = globales().dir.getName() // get the name of the directory.
  return rep
}

I would like to use jsdoc so that when I write this code, the return type of the variable "dir" can display 'DriveApp.Folder'. Basically, specify for all keys within the 'data' structure in 'global' function : the type of the data (e.g., a string, a number, a DriveApp.Folder)

Something like @param {string} to precise function parameter type.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Seems like you're looking for the @property tag. Based on your code you can try something like the following:

/**
*Returns an Object with some global variables
*
*@function globales
*@property {DriveApp.Folder} dir - Folder ID
*@property {String} sinky - Some string
*@property {int} numberino - Some number
*@returns {Object} - Array with different data
*
*/

function globales() {
  var data = {
    dir: DriveApp.getFolderById('id'),
    sinky: "test",
    numberino : 42
  };
  return data;
}


function test()
{
  var rep = globales().dir.getName() // get the name of the directory.
  return rep
}

And the output in the documentation would be:

enter image description here

May vary depending on how you want to format it but this should work. If your function has input parameters you can use the @param tag and it will add a separate table.

about 4 years ago · Juan Pablo Isaza Relatório
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