Skip to content

[js_interop] No error on Wasm when getProperty returns an incompatible type #61395

@sgrekhov

Description

@sgrekhov

The code below produces run-time error on dart2js but no error on dart2wasm.

main() {
  eval(r'''
    globalThis.object1 = {
      p1: 1
    };
  ''');
  print((globalContext["object1"] as JSObject).getProperty<JSString>("p1".toJS)); // On dart2js: TypeError: 1: type 'int' is not a subtype of type 'String'
}

On dart2wasm 1 is printed. I believe that there should be a run-time error on dart2wasm as well.

cc @srujzs @osa1

Dart SDK version: 3.10.0-edge.33697720bf2aba98e4ae3277e9d60d15621188b2 (main) (Sat Aug 23 14:58:03 2025 -0700) on "linux_x64"

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