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

Can't compile without this inside extension. #60270

Open
ykmnkmi opened this issue Mar 7, 2025 · 2 comments
Open

Can't compile without this inside extension. #60270

ykmnkmi opened this issue Mar 7, 2025 · 2 comments
Labels
area-dart-model Use area-dart-model for issues related to packages analyzer, front_end, and kernel. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.

Comments

@ykmnkmi
Copy link
Contributor

ykmnkmi commented Mar 7, 2025

If I remove this. inside this extension:

extension on HTMLElement {
  @JS('__click')
  external ExternalDartReference<void Function(Event event)?> onClickReference;

  void Function(Event event)? get onClick__ {
    return this.onClickReference.toDartObject;
  }

  set onClick__(void Function(Event event)? onClick) {
    this.onClickReference = onClick.toExternalReference;
  }
}

I get these errors:

web/main.dart:37:12: Error: Undefined name 'onClickReference'.
    return onClickReference.toDartObject;
           ^^^^^^^^^^^^^^^^
web/main.dart:42:5: Error: Setter not found: 'onClickReference'.
    onClickReference = onClick.toExternalReference;
    ^^^^^^^^^^^^^^^^

DartPad example.

@ykmnkmi ykmnkmi added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Mar 7, 2025
@kevmoo
Copy link
Member

kevmoo commented Mar 7, 2025

CC @srujzs

@srujzs srujzs added the area-dart-model Use area-dart-model for issues related to packages analyzer, front_end, and kernel. label Mar 7, 2025
@srujzs
Copy link
Contributor

srujzs commented Mar 7, 2025

Interesting, this looks to be specific to external fields that exist within an extension (regardless of whether the on-type is an extension type or a class). While it does get treated as a getter-setter pair by the CFE, the parsing seems to differ. cc @johnniwinther

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-model Use area-dart-model for issues related to packages analyzer, front_end, and kernel. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
Projects
None yet
Development

No branches or pull requests

3 participants