You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
typedefItemRenderer<T> =StringFunction(T);
abstractclassDog {
Stringget name;
}
classMyComponent {
StringitemRenderer(Dog dog) => dog.name;
}
classItemListComponent<T> {
ItemRenderer<T> itemRenderer;
}
voidmain() {
var myComponent =newMyComponent();
var childComponent =newItemListComponent<dynamic>();
// TypeError: Type '(Dog) => String' is not a subtype of type '(dynamic) => String'
childComponent.itemRenderer = myComponent.itemRenderer;
}
We're going to work on #68, but until then, users need an ergonomic way to untype these types of functions/closures, but retain the some benefits of static typing (IDE auto-completion, go-to definition, avoid dynamic calls).
My proposal is to add a package:angular/meta.dart (we were already planning this for @visibleForTemplate), and include a few helper functions to cast callbacks into forms that are suitable for AngularDart components, with the goal of removing/fixing these cases when we fix #68:
(I am proposing this for v5 final, as a migration aid from v4)
Another advantage is we can leverage unsafeCast (internal function) to reduce the amount of runtime casts that occur in production code, retaining performance from v4 (and Dart 1) as much as possible.
The text was updated successfully, but these errors were encountered:
We don't have a dependency on quiver (intentionally, it breaks too often). The reason for Angular is to track the usages of it, and once we have proper generic support we could @deprecate it with references on how to use template generics. We could call this castCallbackForAngular if we want to make that more clear, of course.
In AngularDart v5 with Dart2, the lack of reified generics definitely hurts:
We're going to work on #68, but until then, users need an ergonomic way to untype these types of functions/closures, but retain the some benefits of static typing (IDE auto-completion, go-to definition, avoid dynamic calls).
My proposal is to add a
package:angular/meta.dart
(we were already planning this for@visibleForTemplate
), and include a few helper functions to cast callbacks into forms that are suitable for AngularDart components, with the goal of removing/fixing these cases when we fix #68:You can see a full proposal, and example, on DartPad:
https://dartpad.dartlang.org/82e79cbcd0c781b9cda557754fbccbf8
(I am proposing this for v5 final, as a migration aid from v4)
Another advantage is we can leverage
unsafeCast
(internal function) to reduce the amount of runtime casts that occur in production code, retaining performance from v4 (and Dart 1) as much as possible.The text was updated successfully, but these errors were encountered: