Skip to content

dartify doesn't convert Promises on dart2wasm #54573

Open
@srujzs

Description

@srujzs

dart:js_interop's dartify doesn't convert Promises to Futures on dart2wasm like dart2js/DDC. Instead it treats it like a JSValue:

import 'dart:js_interop';
import 'package:async_helper/async_helper.dart';

@JS('Promise.resolve')
external JSAny resolve(String s);

void main() {
  asyncTest(() async {
    await (resolve('').dartify() as Future<JSAny?>);
  });
}

results in:

Type 'JSValue' is not a subtype of type 'Future<JSValue?>' in type cast

but passes on dart2js/DDC.

The culprit is

Object? dartifyRaw(WasmExternRef? ref) {
, where we never check for Promises. DDC/dart2js does:
if (_isJavaScriptPromise(o)) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dart2wasmIssues for the dart2wasm compiler.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

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions