i am creating an appscript add-on using typescript and i did use tsc to compiles TypeScript code into JavaScript and clasp push to push it into the appscript editor but i am getting this error
ypeError: Object.defineProperty called on non-object
this is the typescript function
export function buildComposeCard(subject: string, sender: string, body: string): GoogleAppsScript.Card_Service.Card {
subject = subject || 'No Subject';
sender = sender || 'Unknown Sender';
body = body ? body.trim() : 'No content available';
const draftButton = CardService.newTextButton()
.setText('Generate Draft')
.setOnClickAction(CardService.newAction()
.setFunctionName('composeAction')); // Adjusted here
const card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Compose Email'))
.addSection(CardService.newCardSection()
.addWidget(CardService.newTextParagraph().setText('Compose your email here.'))
.addWidget(CardService.newKeyValue().setTopLabel('Subject').setContent(subject))
.addWidget(CardService.newKeyValue().setTopLabel('From').setContent(sender))
.addWidget(draftButton)
.addWidget(CardService.newTextParagraph().setText(body)))
.build();
return card;
}
after i push it to the appsscript editor i get this function
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildComposeCard = void 0;
function buildComposeCard(subject, sender, body) {
subject = subject || 'No Subject';
sender = sender || 'Unknown Sender';
body = body ? body.trim() : 'No content available';
const draftButton = CardService.newTextButton()
.setText('Generate Draft')
.setOnClickAction(CardService.newAction()
.setFunctionName('composeAction')); // Adjusted here
const card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Compose Email'))
.addSection(CardService.newCardSection()
.addWidget(CardService.newTextParagraph().setText('Compose your email here.'))
.addWidget(CardService.newKeyValue().setTopLabel('Subject').setContent(subject))
.addWidget(CardService.newKeyValue().setTopLabel('From').setContent(sender))
.addWidget(draftButton)
.addWidget(CardService.newTextParagraph().setText(body)))
.build();
return card;
}
exports.buildComposeCard = buildComposeCard;
which give me the error when i run it on the appsscript
i tried updating the dependencies still not working
New contributor
hamed elghoul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.