dart-lang / setup-dart

A GitHub Action to install and setup a Dart SDK.
BSD 3-Clause "New" or "Revised" License
194 stars 38 forks source link

update to the latest JS interop #95

Closed devoncarew closed 1 year ago

devoncarew commented 1 year ago

Hi - it looks like we need to update to a newer version of JS interop here. @srujzs - can you advise what the changes should be? I assume this would be mostly mechanical; if you can give pointers to one or two of the issues below I can extrapolate for the rest. Thanks!

For Dart 3.1.0-294.0.dev:

  error • lib/main.dart:21:29 • The argument type 'String' can't be assigned to the parameter type 'JSString'. •
          argument_type_not_assignable
  error • lib/main.dart:22:13 • The getter 'isEmpty' isn't defined for the type 'JSString'. Try importing the library that defines
          'isEmpty', correcting the name to the name of an existing getter, or defining a getter or field named 'isEmpty'. •
          undefined_getter
  error • lib/main.dart:23:13 • A value of type 'String' can't be assigned to a variable of type 'JSString'. Try changing the type of the
          variable, or casting the right-hand type to 'JSString'. • invalid_assignment
  error • lib/main.dart:27:32 • The argument type 'String' can't be assigned to the parameter type 'JSString'. •
          argument_type_not_assignable
  error • lib/main.dart:28:16 • The getter 'isEmpty' isn't defined for the type 'JSString'. Try importing the library that defines
          'isEmpty', correcting the name to the name of an existing getter, or defining a getter or field named 'isEmpty'. •
          undefined_getter
  error • lib/main.dart:29:16 • A value of type 'String' can't be assigned to a variable of type 'JSString'. Try changing the type of the
          variable, or casting the right-hand type to 'JSString'. • invalid_assignment
...
srujzs commented 1 year ago

Ah, it looks like this repo was using the typedefs we had for JS types (which have since been reified for a while now). So the JS types are statically separate types now, which is why you see all these errors.

We've started allowing external signatures to have Dart primitives on all backends (so num (and subtypes), bool, String are ok), so you can replace your external definitions in node/ with parameters that accept String. If for whatever reason you want to maintain JSString, you can also do .toJS and .toDart to go back and forth.

The non-String related errors that I can see are:

https://github.com/dart-lang/setup-dart/blob/007c7cbb377cdbdf8922e2f8c4172dc60fbaaf9a/lib/node/actions/http_client.dart#L7

Object errors

Let me know if you have any questions, thanks!

devoncarew commented 1 year ago

Thanks! I was able to address the analysis issues. I'm now seeing some compilation issues:

https://github.com/dart-lang/setup-dart/pull/97

Do you mind taking a look to see if something jumps out for you? From the error messages - Inline class member is marked 'external', but the representation type of its inline class is not a valid JS interop type - it's not immediately clear what's going wrong.