Acknowledged
CIQQA-3455

Linter expects a Number (only) as argument for the Dict.hasKey() method for -l1 and above

Looks like I can't post code, nor images, nor anything. So you will have to live with my description:
When retrieving a dictionary from the storage:
var foo = Toybox.Application.Storage.getValue("foo")
and using
foo.hasKey("bar")
on said dictionary, the linter expects a number only as argument and the code fails to compile.
Error message:
Invalid '$.Toybox.Lang.String' passed as parameter 1 of type '$.Toybox.Lang.Number'.
Parents
  • TL;DR: cast the return type of getValue and the error will go away:
    Ofc the problem here is that nothing prevents you from casting to the wrong type - i.e. a type which is not returned by getValue[] at all, or a type that doesn't match the value you actually stored in Storage.
    [4/x]
Comment
  • TL;DR: cast the return type of getValue and the error will go away:
    Ofc the problem here is that nothing prevents you from casting to the wrong type - i.e. a type which is not returned by getValue[] at all, or a type that doesn't match the value you actually stored in Storage.
    [4/x]
Children
No Data