Skip to content
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

Analyzer should optionally warn when public methods don't have type annotations #17986

Closed
DartBot opened this issue Apr 2, 2014 · 10 comments
Closed
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Apr 2, 2014

This issue was originally filed by armiller...@google.com


Leaving off type annotations from public methods can be nice for development of a library, but makes the library harder to use. It would be nice if the analyzer could optionally warn/error when public methods/functions don't have type annotations to help encourage library writers to properly annotate their APIs.

@kevmoo
Copy link
Member

kevmoo commented Apr 2, 2014

I've not been a fan of the 'omit dynamic' rule for this reason. It's hard to differentiate between something explicit or something forgotten.


Removed Type-Defect label.
Added Type-Enhancement, Analyzer-Hint, Triaged labels.

@anders-sandholm
Copy link
Contributor

Added Area-Analyzer label.

@bwilkerson
Copy link
Member

Added this to the Later milestone.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@tfortes
Copy link

tfortes commented Apr 9, 2014

+1 to warnings when public types are not specified.
...and please also add a flag to warn when ANY non-inferable types are missing a type declaration.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@tfortes
Copy link

tfortes commented Nov 13, 2014

I just saw a demo of typescript in VisualStudio where they have the option of treating missing type declarations as "no type" instead of "any" (dynamic), which highlights where you should add type annotations.

This is pretty much the flag/mode that is discussed here. Please reconsider the priority for this!

@DartBot
Copy link
Author

DartBot commented Nov 14, 2014

This comment was originally written by @mezoni


Even if this is useful this will be a great contradiction of the basic concept of the proposed Gilad Bracha.

If we recognize that it is useful we should turn out that all these years, the whole concept was false.

============
https://www.dartlang.org/articles/optional-types/

Optional Types in Dart
Written by Gilad Bracha
October 2011 (updated September 2012)

One of the Dart programming language’s most innovative features is the use of optional types.
============

But get warning (as proposed here) should means that a whole concepts are wrong.
Because this will prevent to use type annotation optionally (do not use them and do not get a warnings).

@DartBot
Copy link
Author

DartBot commented Jan 14, 2015

This comment was originally written by beatgammit...@gmail.com


But get warning (as proposed here) should means that a whole concepts are wrong.

I don't think that's true if it's off by default.

Having this tool is very useful when working on a library since it gives a TODO list for documentation.

I still think optional types is a very good thing, since it allows rapid iteration in the beginning and documentation when the code stabilizes. Libraries should nearly always be stable, so they should nearly always have complete type annotations.

@DartBot DartBot added Type-Enhancement analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Jan 14, 2015
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@srawlins
Copy link
Member

This is covered by the linter: type_annotate_public_apis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

7 participants