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

Uncaught TypeError: 'JSArray' is not a subtype of type 'List<ResizeObserverEntry>' #104

Closed
kenzieschmoll opened this issue Apr 29, 2019 · 2 comments

Comments

@kenzieschmoll
Copy link

I have some resize observer code that looks as follows:

    final observer = html.ResizeObserver(allowInterop((entries, _) {
       // do something
    }));
    observer.observe(element);

And in the dart2js version of the web app, I am getting a TypeError. I do not get this error when using webdev serve.

Uncaught TypeError: Instance of 'JSArray': type 'JSArray' is not a subtype of type 'List<ResizeObserverEntry>'
    at Object.wrapException (main.dart.js:1115)
    at Object.assertSubtype (main.dart.js:1975)
    at EventDetails_closure.call$2 (main.dart.js:42132)
    at Object.Primitives_applyFunction (main.dart.js:1001)
    at Object.Function_apply (main.dart.js:5440)
    at _callDartFunctionFast (main.dart.js:7374)
    at main.dart.js:7365
    at Function.call$2 (main.dart.js:54318)
    at invokeClosure (main.dart.js:1307)
    at ResizeObserver.<anonymous> (main.dart.js:1325)
@rakudrama
Copy link
Member

Can you show more of the code, especially something declared with the list type in question?

JavaScript arrays coming from JS-interop are currently considered by dart2js to implement List<dynamic>, which is not assignable to List<ResizeObserverEntry>.

I don't think this is really a html issue so much as a JS-interop issue.
There is an issue to improve these JS-interop issues:
dart-lang/sdk#35084
And a proposal:
https://github.com/dart-lang/sdk/blob/js_interop/pkg/js/proposal.md

@kevmoo
Copy link
Member

kevmoo commented Apr 29, 2019

Issue moved to dart-lang/sdk #36798 via ZenHub

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

No branches or pull requests

3 participants