-
Notifications
You must be signed in to change notification settings - Fork 1.7k
avoid_annotating_with_dynamic and new typedef #57789
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
Comments
I don't think so. In both cases you're annotating that the parameter to the function has the type |
Depending on what the purpose of linter is, an 'ignore' comment may be the right solution. I'm not trying to dispute it though, because I'm new to Dart and even more to the linter. What I want to say is, contrary to this check description, If the purpose of this check is to discourage the use of |
The purpose of the linter is to help users catch code patterns that, while valid Dart, they would prefer to not have in their code base. Sometimes those patterns are purely a matter of preference, sometimes they help avoid errors in the code.
You're right. I now think the rule has a bug in that it fails to allow for the generic function type syntax. |
I think @dotdoom is correct here. The lint rule says to not type typedef CallbackWithParameter = Future<void> Function(dynamic);
// or
typedef CallbackWithParameter = Future<void> Function(dynamic parameter); but we cannot write typedef CallbackWithParameter = Future<void> Function(parameter); (unlike in a function-typed parameter), so the the lint should not report this, as there is no implicit dynamic in function types. |
I'm struggling to make an otherwise useful
avoid_annotating_with_dynamic
work with my typedef:both are syntactically valid, but none satisfies this lint check. Templatizing
CallbackWithParameter
fixes this, but it's not exactly what I'm looking for. Is this check incompatible with the new typedefs?The text was updated successfully, but these errors were encountered: