Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix returning null from ExtendScript with evalTS #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ggrossman
Copy link

@ggrossman ggrossman commented Aug 4, 2023

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
Copy link
Author

An alternative fix would be to add a line

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

@ggrossman ggrossman changed the title Fix returning null or undefined from ExtendScript with evalTS Fix returning null from ExtendScript with evalTS Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant