-
Notifications
You must be signed in to change notification settings - Fork 38
updates to move away from dart:js_util #148
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
Conversation
lib/node/process.dart
Outdated
@@ -17,6 +17,7 @@ extension type Process(JSObject obj) { | |||
external JSObject get _env; | |||
|
|||
/// Read the environment variable [variable]. | |||
// TODO(devoncarew): move away from using dart:js_util `getProperty`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srujzs - quick interop question. If I have a JS object, how to I access named fields (like 'PWD'
or 'PATH'
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, JSObjectUnsafeUtilExtension.getProperty
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the docs for https://api.dart.dev/stable/latest/dart-js_interop_unsafe/JSObjectUnsafeUtilExtension.html be updated? It says but takes and returns a Dart value
but the sig indicates it takes a dart value and returns a JSAny.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, or just []
. You could also add an extension type for _env
and add external
fields with the expected names.
Thanks for the catch! https://dart-review.googlesource.com/c/sdk/+/409480
lib/main.dart
Outdated
'allowRedirects': true, | ||
'maxRedirects': 3, | ||
'allowRetries': true, | ||
'maxRetries': 3, | ||
}) as JSObject?, | ||
}.toJSBox, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srujzs - also, I don't see a .toJS
on Dart Maps, but do see a toJSBox
. Here, I'm trying to convert to a regular JSObject.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just use .jsify()
like you were before - it's just an extension method now. This should translate the map into a JS object using the string keys as property names just like before. toJSBox
creates an explicit box around the object so that you can pass it back to the Dart runtime later so it's not the right fit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks
npm update
to get the latest versions of node packagesContribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.