I am currently developing an application that is built on Angular 2.4 and Typescript 2.8.3. In this project, I have created a generic map structure and need to determine its size after adding or removing elements.
let map = new Map<String, String>();
...
When trying to retrieve the size using map.size()
, I encounter the following error:
Cannot invoke an expression whose type lacks a call signature in Typescript. Type 'Number' does not have compatible call signatures. ts(2349)
I have also attempted the code snippet below, but it consistently returns 0
even when the map has elements stored within it!
Objects.keys(map).length // 0