<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Property &amp;quot;add doesn't exist in map&amp;quot; when trying to implment typescript with react in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091800#M74395</link>
    <description>&lt;P&gt;If I understand, in your code you have something where it looks like this maybe?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addToMap(target: MapView | Map) {
  // this is what you are trying to do
  // target.add(layer)
  // but you need to let TypeScript know what type it should expect.
  // you can do something like this, I haven't tested
  if (!Boolean(target.container)) {
    // should work because container is not on Map
    // but is on MapView
    // now TS knows what it is using
    target.add(layer);
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That might help, if not, do have a reproducible sample of the issue.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Aug 2021 16:55:19 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-08-24T16:55:19Z</dc:date>
    <item>
      <title>Property "add doesn't exist in map" when trying to implment typescript with react</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091793#M74394</link>
      <description>&lt;P&gt;I am trying to add typescript to the react code base that I have developed. Using the type "&lt;SPAN&gt;__esri&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;MapView" seems to have caused the following error, when trying to do "map.add" when trying to add layers to the view:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;"Property 'add' does not exist on type 'MapView | Map'. Property 'add' does not exist on type 'MapView'.&lt;/P&gt;&lt;P&gt;Am I using the wrong type here? Can someone point me to the right direction which type I should be using for MapView?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 16:44:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091793#M74394</guid>
      <dc:creator>KenjooYeap</dc:creator>
      <dc:date>2021-08-24T16:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Property "add doesn't exist in map" when trying to implment typescript with react</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091800#M74395</link>
      <description>&lt;P&gt;If I understand, in your code you have something where it looks like this maybe?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function addToMap(target: MapView | Map) {
  // this is what you are trying to do
  // target.add(layer)
  // but you need to let TypeScript know what type it should expect.
  // you can do something like this, I haven't tested
  if (!Boolean(target.container)) {
    // should work because container is not on Map
    // but is on MapView
    // now TS knows what it is using
    target.add(layer);
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That might help, if not, do have a reproducible sample of the issue.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 16:55:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091800#M74395</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-08-24T16:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Property "add doesn't exist in map" when trying to implment typescript with react</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091876#M74396</link>
      <description>&lt;P&gt;Thanks for the hint, my function was returning two possible types and I have to cast it to a tuple so that it's assigned to the right type.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 18:41:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/property-quot-add-doesn-t-exist-in-map-quot-when/m-p/1091876#M74396</guid>
      <dc:creator>KenjooYeap</dc:creator>
      <dc:date>2021-08-24T18:41:03Z</dc:date>
    </item>
  </channel>
</rss>

