SDK 4.2.0 WARNING: Cannot determine if container access is using container type.

Hello,

I get a message on my SIM (yellow text):

Cannot determine if container access uses container type.

What type of container should i use for this code?

This is an OWM feature

function responseCallback(responseCode as Number, data as Dictionary or String or Null) as Void {

var backgroundData as Dictionary;


if (responseCode == 200) {

backgroundData = {
"1" => responseCode,
"2" => Time.now().value(),
"3" => data["main"]["temp"],
"4" => data["weather"][0]["icon"],

};
} else {
backgroundData = {
"1" => responseCode,
"2" => Time.now().value(),
};
}

Background.exit(backgroundData);
}

Thank you

  • Do you have strict type checking enabled?  I just use the default and that declaration works fine.

    Given this worked for you earlier, this should work "Dictionary<PropertyKeyType,PropertyValueType>?"

  • I don't want to post here repeatedly but I keep getting the latest notification for this feature, does anyone have an idea how to fix this?

    And this doesn't work for me either:

    public function OnReceiveOpenLocationUpdate(responseCode as Number, data as Dictionary<PropertyKeyType,PropertyValueType>?) as Void {

    Function:

    public function OnReceiveOpenLocationUpdate(responseCode as Number, data as Dictionary or String or Null) as Void {

    ..........

  • Either turn off strict type checking it you have to tell the compiler in the function declaration what type data is. I mean you only tell it can be a Dictionary but don't tell what types the keys, values can be

  • So I found out by trial and error that the error of the container is not in "data", but ultimately in _city.

    Here I have a question, what should I give as _city?

    I currently have it like this:

    private var _city as Array<String> = ["unk"] as Array<String>;

  • 1. the takeaway should be to include all the relevant code when posting in the forum Slight smile

    2. I can only repeat things already written a couple of times in this thread: either remove the strict typechek or make sure you declare the types properly, especially data in the function declaration. The compiler doesn't know what types the key, values can be. I don't know it either. When you put there: data as Dictionary<Foo, Bar> then I'll tell you to declare _city as Bar.

  • Well, it doesn't help, I asked politely, because I think most developers have a similar problem. Yes, I can turn off the check, but that won't make much sense since I'm learning to code with SDK 4.2.0 without bypassing the check.

    I also don't know what happens if I turn off "type checking" and compile the whole project, will it create the resulting file for me? So far no one has explained it to me when I asked about it...

  • Look, I am one of those who usually say: don't turn off strict typecheck. In my code I only use strict typecheck. But I told you politely 3 times what's the problem, and you're not trying to fix it, so how can I help you?

  • I don't understand why I have to turn off the check when Garmin built it in there for some reason?

    I also don't understand that if I turn it off, the resulting file is not created at all?

    Dale, in the first post you said it's just copy and paste and I copy and paste and the error doesn't go away, so I need to know what type of container is _city for example?

    For example, where I can find it, that is more than enough for me... I don't want anything more.

  • Type checking can be turned off (it started being the default with the 4.1.6 SDK).  If you turn it off and can't build a prg, that means you might have something wrong when you actually compile.  What do do you see in the console of you turn off type checking?

  • When I turn off type checking I can't see anything in the console and the watch face works normally. I just wanted to learn how to write code to help SDK 4.2.0 without bypassing the check.

    This might sound weird, but I'll ask, do you also turn off type checking when building code?