Skip to content

Commit

Permalink
Fix bad generic typing on Object.keys
Browse files Browse the repository at this point in the history
  • Loading branch information
greglittlefield-wf committed Oct 10, 2023
1 parent 7ca0cb8 commit 2d3e1e3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/react_client/js_backed_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class JsBackedMap extends MapBase<dynamic, dynamic> {
factory JsBackedMap.fromJs(JsMap jsOther) => JsBackedMap()..addAllFromJs(jsOther);

// Private helpers with narrower typing than we want to expose, for use in other methods
List<String> get _keys => objectKeys(jsObject);
List<dynamic> get _keys => objectKeys(jsObject);
// Use keys to access the value instead oof `Object.values` since MSIE 11 doesn't support it
List<dynamic> get _values => _keys.map((key) => this[key]).toList();

Expand Down
3 changes: 2 additions & 1 deletion lib/src/js_interop_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'dart:js_util';
import 'package:js/js.dart';

@JS('Object.keys')
external List<String> objectKeys(Object object);
// We can't type this as List<String> due to https://github.com/dart-lang/sdk/issues/37676
external List<dynamic/*String*/> objectKeys(Object object);

@JS()
@anonymous
Expand Down
2 changes: 1 addition & 1 deletion lib/src/react_client/private_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ T validateJsApiThenReturn<T>(T Function() computeReturn) {
Map<String, dynamic> unjsifyContext(InteropContextValue interopContext) {
// TODO consider using `contextKeys` for this if perf of objectKeys is bad.
return {
for (final key in objectKeys(interopContext))
for (final key in objectKeys(interopContext).cast<String>())
key: (getProperty(interopContext, key) as ReactDartContextInternal?)?.value
};
}
Expand Down

0 comments on commit 2d3e1e3

Please sign in to comment.