need a option to treat variable defined by var as typed, not dynamic #20693
Labels
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
closed-duplicate
Closed in favor of an existing report
type-enhancement
A request for a change that isn't a bug
Milestone
This issue was originally filed by @rinick
people use "var" to define properties because they don't want to type the whole type name like
/Map<String, List<DivElement>>/ var map = getDivMap();
but in most cases I still want the variable to be typed, not dynamic.
there should be an option to make dartEditor and dart2js use a strict mode to check "var" if it's defined with an assignment.
var str = "hello"; // str is String
str = 123; // warning A value of type 'int' cannot be assigned to a variable of type 'String'
var str2; // this is dynamic
str2 = "hello";
str2 = 123; // no problem
The text was updated successfully, but these errors were encountered: