Skip to content

Support rest params in package:js #24623

@ochafik

Description

@ochafik

A @varargs or @rest annotation would be useful in two use-cases:

  • To implement ES6 JS helpers with rest params in DDC (see Write all of the runtime in Dart. dart-archive/dev_compiler#310):

    mixin(base, @js.varargs mixins) {...}

    Would be compiled by DDC to:

    function mixin(base, ...mixins) {...}
  • To call external (or internal) methods with rest params. The following call:

    foo(a, b, js.varargs(others)) // or js.rest(others)

    Would be compiled to ES6 code by DDC:

    foo(a, b, ...others)

    And to something like the following ES5 code by dart2js (some devil in the this binding details):

    foo.apply(null, [a, b].concat(others))

Metadata

Metadata

Assignees

Labels

web-js-interopIssues that impact all js interop

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions