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

275
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
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