Skip to content

type_annotate_public_apis reports missing type for static const #57767

Closed
dart-archive/linter
#1541
@chalin

Description

@chalin

Consider the following class member declaration:

class Queue {
  static const initialCapacity = 16;
}

The type_annotate_public_apis lint causes this issue to be reported:

lint • Type annotate public APIs at lib/language_tour/classes/misc.dart:22:16 • type_annotate_public_apis

Being a static const, its type is fully determined at compile time from the initializer, so a type annotation would be redundant, and certainly should not be required -- as the lint message seems to suggest.

Of course, such a static const w/o an explicit type annotation can end up having type dynamic, which might not be desirable, but that is another issue addressed via the --no-implicit-dynamic flag IMHO.

cc @munificent @kwalrath @kevmoo

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-positivetype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions