Skip to content

Allow to declare fields as 'external' for simpler JS interop. #27561

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

Open
drecdroid opened this issue Oct 11, 2016 · 2 comments
Open

Allow to declare fields as 'external' for simpler JS interop. #27561

drecdroid opened this issue Oct 11, 2016 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug

Comments

@drecdroid
Copy link

Currently you have to write both getter and setter to have a field access an external JS field.
There are maybe some language restrinctions that don't allow fields as external but an annotation could solve this problem.

Now:

class CircularChartData{
  ...
  external String get color;
  external set color(String v);
  ...
}

Proposal:

class CircularCharData{
  ...
  external String color;
  ...
}

or:

class CircularCharData{
  ...
  @external String color;
  ...
}

or:

class CircularCharData{
  ...
  external String accessor color;
  ...
}
@lrhn
Copy link
Member

lrhn commented Oct 11, 2016

I have no conceptual problem with allowing an "external field" as a shorthand for a pair of external getter and setter.
Since it is "external", it shouldn't introduce the normal field storage, only the signatures of the getters and setters. You can't initialize such a field in a generative constructor, so it's basically equivalent to implementing an interface with a field signature, and expecting the actual implementation of the getter/setter to come from somewhere externally.

@lrhn lrhn added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug labels Oct 11, 2016
@alexmarkov
Copy link
Contributor

Related: #42560.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants