admin管理员组文章数量:1390707
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}
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}
Share
Improve this question
edited Mar 26, 2024 at 22:29
VLAZ
29.1k9 gold badges63 silver badges84 bronze badges
asked Mar 19, 2021 at 1:47
nikko.guynikko.guy
611 silver badge8 bronze badges
1
- Wele to Stack Overflow. Please add a brief description of your search efforts as is suggested in How to Ask. Also add more details of the IDE that you are using and if you are open to use another one. – Wicket Commented Mar 19, 2021 at 2:47
2 Answers
Reset to default 4Google 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.
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
本文标签: javascriptcreate a function with specific parameter typesStack Overflow
版权声明:本文标题:javascript - create a function with specific parameter types - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744598866a2614945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论