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

Add more than one variable arguments. #340

Open
ykmnkmi opened this issue Feb 13, 2025 · 3 comments
Open

Add more than one variable arguments. #340

ykmnkmi opened this issue Feb 13, 2025 · 3 comments
Assignees

Comments

@ykmnkmi
Copy link

ykmnkmi commented Feb 13, 2025

For example Element methods with variable arguments, instead of a single argument:

external void prepend(JSAny nodes);
external void append(JSAny nodes);
external void before(JSAny nodes);
external void after(JSAny nodes);

generate rest arguments as optional positional arguments:

external void prepend(JSAny node, [JSAny node2, JSAny node3, ..., JSAny node9]);
external void append(JSAny node, [JSAny node2, JSAny node3, ..., JSAny node9]);
external void before(JSAny node, [JSAny node2, JSAny node3, ..., JSAny node9]);
external void after(JSAny node, [JSAny node2, JSAny node3, ..., JSAny node9]);

I have some cases with 2 ~ 4 arguments. Currently, I use extension types and dart:js_interop (target.callMethod('append'.toJS, node1, node2);)

Also, nodes for a single argument name sounds like it expect list of nodes, instead one node.

@srujzs srujzs self-assigned this Feb 14, 2025
@srujzs
Copy link
Contributor

srujzs commented Feb 14, 2025

Indeed, it's misleading and we should really be providing multiple arguments. We've been typically implementing variadic arguments as ~4 arguments in the SDK (callMethod from dart:js_interop_unsafe for example) so I'm tempted to keep it aligned there.

@ykmnkmi
Copy link
Author

ykmnkmi commented Feb 14, 2025

@srujzs I can work on this issue.

@srujzs
Copy link
Contributor

srujzs commented Feb 14, 2025

Thanks, go for it! Happy to review the PR and answer any questions about the translator.

#339 is also related if you think it would make sense to do at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants