Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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}
like image 516
nikko.guy Avatar asked Oct 17 '25 11:10

nikko.guy


2 Answers

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

like image 136
sasanom Avatar answered Oct 20 '25 03:10

sasanom


Google Apps Script is based on JavaScript which is not a statically typed language. You can't enforce types. You will need to manually check the types in your function body.

like image 33
Ruan Avatar answered Oct 20 '25 03:10

Ruan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!