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

update to the latest JS interop #95

Closed
devoncarew opened this issue Jul 11, 2023 · 2 comments · Fixed by #97
Closed

update to the latest JS interop #95

devoncarew opened this issue Jul 11, 2023 · 2 comments · Fixed by #97

Comments

@devoncarew
Copy link
Member

devoncarew commented Jul 11, 2023

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
Copy link

srujzs commented Jul 11, 2023

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:

  • You should call .toJS on the list to pass it to JSArray. You should also jsify (via dart:js_util) the Map (and label it JSObject) instead of passing a Map directly.

Object errors

  • These look like Strings/JSStrings, they might just need a cast once you replace all externals with String.

Let me know if you have any questions, thanks!

@devoncarew
Copy link
Member Author

devoncarew commented Jul 11, 2023

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

#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.

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

Successfully merging a pull request may close this issue.

2 participants