Search code examples
javascriptgoogle-apps-scriptjsdoc

create a function with specific parameter types


I'm making a Google Apps Script function that takes two parameters: a Spreadsheet object and a Transaction object, which I created. How can I specify that I want my parameters to have that type?

I'm looking for this functionality:

function addTransaction(Spreadsheet sheet,Transaction t){//blah blah blah doesn't matter}

Solution

  • You can use JSDoc syntax to show hints, like this. (not sure what Transaction means, but hope you get the idea)

    /**
     * @param {SpreadsheetApp.Spreadsheet} sheet
     * @param {Transaction} t
     */
    function addTransaction(sheet, t){ blah blah}
    

    See here or more details: https://jsdoc.app/tags-param