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

Array destructuring transpiles into incompatible code #30

Closed
timhaywood opened this issue Jun 7, 2022 · 5 comments
Closed

Array destructuring transpiles into incompatible code #30

timhaywood opened this issue Jun 7, 2022 · 5 comments

Comments

@timhaywood
Copy link
Collaborator

Unfortunetly, babel (purposefully) transpiles array destructuring into code that uses Array.isArray, even if that's not available in the target environment.

More info in this issue on the babel repo:
babel/babel#11195

Don't expect a fix or anything, just wanted to call it out in case you hadn't run across it and wanted to call it out as a known limiation in the README or something.

I've just replaced the destructuring in my scripts manually.

Appreciate your hard work! Feel free to close without comment :)

@mgomez-tubs
Copy link

I ran across this today lol. Should probably be mentioned in the README. Luckily I dind't spent too much time debugging it (which is kinda hard, since it appears almost from nowhere). However, I found out that having certain panels open (?) allows you to use the Array.isArray function.

@timhaywood
Copy link
Collaborator Author

Yeah good idea, let me add a PR for updating the readme 👍

As for having panels open, scripts have access to the global object, so some may modify the global Array prototype to add isArray, which is why your script has access to it when they're open.

@justintaylor-dev
Copy link
Contributor

@timhaywood @mgomez-tubs thanks for brining this up!

Built-in and custom Ponyfills have been implemented in 0.4.0 (see the Readme for details).

I've added a Ponyfill for Array.isArray so array destructuring now works in ExtendScript.

Let me know if you run into any other issues. 🍻

@justintaylor-dev
Copy link
Contributor

resolved in d3ca479

@timhaywood
Copy link
Collaborator Author

Amazing, thanks Justin!

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

No branches or pull requests

3 participants