google / clasp

🔗 Command Line Apps Script Projects
https://developers.google.com/apps-script/guides/clasp
Apache License 2.0
4.59k stars 428 forks source link

Exported Google Sheets functions broke #947

Open mheffner opened 2 years ago

mheffner commented 2 years ago

(Note: Non-breaking issues are likely not to be prioritized. Please consider a PR in addition to your issue)

Expected Behavior

I'm returning to a previous Google apps script I had built for Google sheets. I haven't worked on it for approximately a year, so it is likely something has changed in the tooling. When I try to build and rerun a test framework I had it is now complaining that it can't find a number of functions, the function names have an additional _1 suffix. I have split the app script out across several Typescript files to modularize the code. I'm looking for any assistance that could return the behavior to the version I had working in the clasp tooling previously.

My layout is similar to the following:

In foo.ts:

export function FOO() {
  ..do something..
}

This function FOO() was callable from a Google sheets cell as =FOO(..). In my test script in test.ts, I had something similar to:

import { FOO } from "../src/foo"

function test_foo() {
   FOO(...)
}

This test function was executed by a command clasp run runAllTests that invoked test_foo.

However, this now throws the error:

ReferenceError: "foo_1" is not defined

What is the correct way to export a function from one function that can be invoked from another file, while also exposing the function as a function in Google sheets?

Actual Behavior

FOO() can be invoked without errors.

Steps to Reproduce the Problem

See above

Specifications

mheffner commented 2 years ago

This is for the project available here: https://github.com/mheffner/aws-pricing (repo issue: https://github.com/mheffner/aws-pricing/issues/47)