Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!