clasp
clasp copied to clipboard
Beginner Question: Why "no functions to run" for the official example?
Hi all, I copied the official example from here
const greeter = (person: string) => {
return `Hello, ${person}!`;
}
let user = 'Grant';
Logger.log(greeter(user));
Expected Behavior
I can run the example in the online editor and see the logs
Actual Behavior
The run button is gray with "No functions to run" tip
Steps to Reproduce the Problem
just clasp push
the code above
Specifications
- Node version (
node -v
): v10.17.0 - Version (
clasp -v
): 2.3.0 - OS (Mac/Linux/Windows): Mac
Apps Script requires that functions be declared at the top-level scope with the function
keyword in order to be visible in the "Run" dropdown. Some developers use a webpack plugin to achieve this, and perhaps it should be built into clasp directly.
@haohaolee please share a link to your google apps script project. @erickoledadevrel transpiled arrow function always end up as regular functions, and the original source seems to be in the global scope…
I still need to see one good use case for webpack with GAS. The only one I ever saw were klugy workaround for trying to mimick node/es modules…
@PopGoesTheWza here is a demo for that https://github.com/haohaolee/clasp-test
@haohaolee Just to be sure, did you paste the sample code directly into the online Google Apps Script editor or did you create a local clasp project, a .ts
file with the sample code and then used clasp push
?