<?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 How to use jsdoc with @arcgis/core for typing help (for interface types) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-jsdoc-with-arcgis-core-for-typing-help/m-p/1554561#M86014</link>
    <description>&lt;P&gt;In this&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-jsdoc-with-arcgis-core-for-typing-help/m-p/1553192/highlight/true#M85984" target="_blank"&gt; post over here&lt;/A&gt; I asked how to get typing support within JavaScript for&amp;nbsp;@&lt;A href="https://www.npmjs.com/package/@arcgis/core" target="_blank"&gt;arcgis/core&lt;/A&gt; classes and functions-- particularly with JSDoc style docstrings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works for most items, but often I want to also import a type interface that is defined in the&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core/interfaces.d.ts file. For example that is where you would find an interface for something like &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult" target="_blank"&gt;HitTestResult,&lt;/A&gt;&amp;nbsp;which is returned from the MapView's hitTest method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In typescript, I can import it for my own function or cast a value to it via `__esri.HitTestResult` as the definition. But I cannot seem to get that to work in JavaScript.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const response /** @type {import("@arcgis/core/interfaces.d.ts").HitTestResult)}  */ = (
    await view.hitTest(event, options)
  );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I use &lt;A href="https://stackoverflow.com/questions/70101584/how-to-cast-typescript-type-in-javascript-using-jsdoc" target="_self"&gt;JSDoc's casting&lt;/A&gt; approach although the above "@arcgis/core/interfaces.d.ts" approach is not recognized.&lt;BR /&gt;&lt;BR /&gt;What is the trick for something like this? I know this is a bit of a JSDoc pattern but I am hoping someone here has a similar workflow and figured this out for the JavaScript Maps SDK already.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&lt;BR /&gt;Saw&lt;A href="https://stackoverflow.com/questions/61867243/reference-a-ts-interface-from-jsdoc" target="_blank"&gt; this on the internet&lt;/A&gt; about type definition file types in javascript/JSDoc but not sure how to implement for my case.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2024 22:49:49 GMT</pubDate>
    <dc:creator>RyanSutcliffe</dc:creator>
    <dc:date>2024-10-31T22:49:49Z</dc:date>
    <item>
      <title>How to use jsdoc with @arcgis/core for typing help (for interface types)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-jsdoc-with-arcgis-core-for-typing-help/m-p/1554561#M86014</link>
      <description>&lt;P&gt;In this&lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-jsdoc-with-arcgis-core-for-typing-help/m-p/1553192/highlight/true#M85984" target="_blank"&gt; post over here&lt;/A&gt; I asked how to get typing support within JavaScript for&amp;nbsp;@&lt;A href="https://www.npmjs.com/package/@arcgis/core" target="_blank"&gt;arcgis/core&lt;/A&gt; classes and functions-- particularly with JSDoc style docstrings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;That works for most items, but often I want to also import a type interface that is defined in the&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/642472"&gt;@ArcGIS&lt;/a&gt;/core/interfaces.d.ts file. For example that is where you would find an interface for something like &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult" target="_blank"&gt;HitTestResult,&lt;/A&gt;&amp;nbsp;which is returned from the MapView's hitTest method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In typescript, I can import it for my own function or cast a value to it via `__esri.HitTestResult` as the definition. But I cannot seem to get that to work in JavaScript.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const response /** @type {import("@arcgis/core/interfaces.d.ts").HitTestResult)}  */ = (
    await view.hitTest(event, options)
  );&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where I use &lt;A href="https://stackoverflow.com/questions/70101584/how-to-cast-typescript-type-in-javascript-using-jsdoc" target="_self"&gt;JSDoc's casting&lt;/A&gt; approach although the above "@arcgis/core/interfaces.d.ts" approach is not recognized.&lt;BR /&gt;&lt;BR /&gt;What is the trick for something like this? I know this is a bit of a JSDoc pattern but I am hoping someone here has a similar workflow and figured this out for the JavaScript Maps SDK already.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&lt;BR /&gt;Saw&lt;A href="https://stackoverflow.com/questions/61867243/reference-a-ts-interface-from-jsdoc" target="_blank"&gt; this on the internet&lt;/A&gt; about type definition file types in javascript/JSDoc but not sure how to implement for my case.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 22:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-jsdoc-with-arcgis-core-for-typing-help/m-p/1554561#M86014</guid>
      <dc:creator>RyanSutcliffe</dc:creator>
      <dc:date>2024-10-31T22:49:49Z</dc:date>
    </item>
  </channel>
</rss>

