Skip to content

[js_interop] Support renaming of parameters in constructors #61220

@fuzzybinary

Description

@fuzzybinary

Dart currently supports renaming properties in an extension type by doing the following:

extension type TestObject._(JSObject _) {
  @JS('property')
  external String prop;
}

However, it is not possible to rename these same properties during construction of the type, especially anonymous types. For example, the following does not work:

extension type TestObject._(JSObject _) {
  @JS('property')
  external String prop;

  external factory TestObject({
    @JS('property') required String,
  });

The a workaround for this is to either leave the names of parameters in the constructor, or to assign the properties in the body of a factory constructor, but having constructor parameter name renaming would be a much cleaner solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.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