Index: lib/src/codegen/js_names.dart |
diff --git a/lib/src/codegen/js_names.dart b/lib/src/codegen/js_names.dart |
index 307e52e0b29df5e052720c615ab12cfd994244d5..867d85b0e89bd769a0e6b8348ba11a175f6258fa 100644 |
--- a/lib/src/codegen/js_names.dart |
+++ b/lib/src/codegen/js_names.dart |
@@ -5,6 +5,7 @@ |
import 'dart:collection'; |
import '../js/js_ast.dart'; |
+import 'package:dev_compiler/src/options.dart'; |
/// Unique instance for temporary variables. Will be renamed consistently |
/// across the entire file. Different instances will be named differently |
@@ -294,3 +295,9 @@ bool invalidStaticFieldName(String name) { |
} |
return false; |
} |
+ |
+/// We cannot destructure named params that clash with JS reserved names: |
+/// see discussion in https://github.com/dart-lang/dev_compiler/issues/392. |
+bool canDestructureNamedParams(Iterable<String> names, CodegenOptions options) { |
+ return options.destructureNamedParams && !names.any(invalidVariableName); |
+} |