updates to move away from dart:js_util#148
Conversation
lib/node/process.dart
Outdated
| 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.
@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.
ah, JSObjectUnsafeUtilExtension.getProperty :)
There was a problem hiding this comment.
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.
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
| 'allowRetries': true, | ||
| 'maxRetries': 3, | ||
| }) as JSObject?, | ||
| }.toJSBox, |
There was a problem hiding this comment.
@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.
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.
npm updateto 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.