Map.addAll after upgrade to GoJS 2

Hi,

I have upgraded from goJS 1.8 to goJS 2.0.17 and now get a compile error in this code:

const templates = new go.Map<string, go.Part>();
this.diagramNodeTemplateProviders.forEach(p => templates.addAll(p.getTemplates()));

with getTemplates defined as:
getTemplates(): go.Map<string, go.Part>;

The error is:

Argument of type 'Map<string, Part>' is not assignable to parameter of type 'Iterator<KeyValuePair<string, Part>> | KeyValuePair<string, Part>[]'.
Type 'Map<string, Part>' is missing the following properties from type 'Iterator<KeyValuePair<string, Part>>': next, hasNext, reset, value, key

I don’t see what I am doing wrong here, since the parameter of the addAll method should be another map, shouldn’t it?
Can you help?

Does it avoid the compilation error if you change your code to be:
templates.addAll(p.getTemplates().iterator)?

No, this gives:

Argument of type 'IMapIterator<string, Part>' is not assignable to parameter of type 'Iterator<KeyValuePair<string, Part>> | KeyValuePair<string, Part>[]'.
  Property 'hasNext' is missing in type 'IMapIterator<string, Part>' but required in type 'Iterator<KeyValuePair<string, Part>>'.

Hmmm, OK, sorry about that. We’ll investigate this later today.

1 Like

OK, this will be fixed in the next release, 2.0.18, probably early next week. Thanks for reporting it.