bolt-cep icon indicating copy to clipboard operation
bolt-cep copied to clipboard

Fix returning null from ExtendScript with evalTS

Open ggrossman opened this issue 2 years ago • 1 comments

Reproduction Steps: Create an ExtendScript function which returns null and call it using evalTS

Expected: evalTS should resolve its promise with the value of null

Actual: evalTS rejects its promise with the value of null, because the line

if (parsed.name === "ReferenceError") {

... attempts to evaluate the .name property of null, which raises a TypeError. This error is caught by the surrounding try/catch, which then rejects the promise with the null value.

Fix: Use safe navigation operator to access parsed.name so that a TypeError is not raised

ggrossman avatar Aug 04 '23 21:08 ggrossman

An alternative fix would be to add a line

if (res === "null") return resolve(null);

ggrossman avatar Aug 05 '23 17:08 ggrossman