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

  • According to the documentation it should accept any Object:

    developer.garmin.com/.../Dictionary.html

    This is false as well, since a key can only be:

    developer.garmin.com/.../Application.html
    Yes it's true that a Dictionary which is returned by Application.Storage.getValue must have keys of PropertyKeyType, but a Dictionary in general can have keys of any Object type. So yeah, you can create a dictionary that takes some random Object has a key, but you won't necessarily be able to put it in storage.
    Error message:
    Invalid '$.Toybox.Lang.String' passed as parameter 1 of type '$.Toybox.Lang.Number'.
    Well, about that. If you change your type check level to to -l 2, you will get many warnings, which will give you a better clue as to what's going on. The error you're getting is kind of a red herring. (I don't claim this is a good dev experience on Garmin's part)
    [1/2]
Comment

  • According to the documentation it should accept any Object:

    developer.garmin.com/.../Dictionary.html

    This is false as well, since a key can only be:

    developer.garmin.com/.../Application.html
    Yes it's true that a Dictionary which is returned by Application.Storage.getValue must have keys of PropertyKeyType, but a Dictionary in general can have keys of any Object type. So yeah, you can create a dictionary that takes some random Object has a key, but you won't necessarily be able to put it in storage.
    Error message:
    Invalid '$.Toybox.Lang.String' passed as parameter 1 of type '$.Toybox.Lang.Number'.
    Well, about that. If you change your type check level to to -l 2, you will get many warnings, which will give you a better clue as to what's going on. The error you're getting is kind of a red herring. (I don't claim this is a good dev experience on Garmin's part)
    [1/2]
Children
No Data