Skip to content

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

Closed
@kevmoo

Description

@kevmoo

@kenzieschmoll commented on Mon Apr 29 2019

I have some resize observer code that looks as follows:

    final observer = html.ResizeObserver(allowInterop((entries, _) {
       _details.uiEventDetails.flameChart.updateForContainerResize();
    }));
    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 commented on Mon Apr 29 2019

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:
#35084
And a proposal:
https://github.com/dart-lang/sdk/blob/js_interop/pkg/js/proposal.md

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