bolt-cep
bolt-cep copied to clipboard
Fix returning null from ExtendScript with evalTS
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
An alternative fix would be to add a line
if (res === "null") return resolve(null);