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

SyntaxError caused by the trailing comma in the function parameters. #181

Open
ahaoboy opened this issue Dec 29, 2023 · 4 comments
Open

Comments

@ahaoboy
Copy link

ahaoboy commented Dec 29, 2023

print(1,)
// SyntaxError: ./i.js: 1: unexpected token in expression: ')'
@ccxvii
Copy link
Owner

ccxvii commented Dec 29, 2023

Trailing commas in function calls are not valid ES5 syntax. These were introduced in a much later revision of the language.

@ahaoboy
Copy link
Author

ahaoboy commented Jan 12, 2024

Trailing commas in function calls are not valid ES5 syntax. These were introduced in a much later revision of the language.

Have you considered supporting trailing comma syntax? Some formatting tools may generate code like this:

print(
  1,
  2,
  3,
)

@Kagami
Copy link

Kagami commented Jan 17, 2024

Some formatting tools may generate code like this

Transpile your code to ES5 before running with MuJS. If you use TypeScript, it's just --target es5 option.

@ahaoboy
Copy link
Author

ahaoboy commented Jan 18, 2024

More issues arise in bundle tools. Library providers will use any available tools to build code, and bundle tools will directly use the code they have built. While some settings or formatting adjustments can be made after bundle, it undoubtedly adds complexity. For Mujs, this functionality indeed goes beyond the scope of ES5. So, feel free to close this issue.

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