<?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 TypeScript errors when using $arcgis.import in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1602411#M86811</link>
    <description>&lt;P&gt;When I try to use $arcgis.import to &lt;A title="Module Loading via CDN" href="https://developers.arcgis.com/javascript/latest/get-started-cdn/#module-loading-via-cdn" target="_blank" rel="noopener"&gt;load modules via CDN&lt;/A&gt;, TypeScript throws an error, saying there is no global variable named $argis.&lt;/P&gt;&lt;PRE&gt;error TS2339: Property '$arcgis' does not exist on type 'Window &amp;amp; typeof globalThis'.&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;How do I get TypeScript to recognize $arcgis?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I've figured out that $arcgis is defined in&amp;nbsp;"@arcgis/core-adapter". I can get Visual Studio Code to stop complaining if I add "@arcgis/core-adapter" to package.json, but tsc still throws the error.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// This gets Visual Studio Code to stop complaining, but not tsc.
const FeatureLayer = await window.$arcgis.import&amp;lt;typeof __esri.FeatureLayer&amp;gt;("@arcgis/core/layers/FeatureLayer.js");&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 03 Apr 2025 16:40:49 GMT</pubDate>
    <dc:creator>JeffJacobson</dc:creator>
    <dc:date>2025-04-03T16:40:49Z</dc:date>
    <item>
      <title>TypeScript errors when using $arcgis.import</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1602411#M86811</link>
      <description>&lt;P&gt;When I try to use $arcgis.import to &lt;A title="Module Loading via CDN" href="https://developers.arcgis.com/javascript/latest/get-started-cdn/#module-loading-via-cdn" target="_blank" rel="noopener"&gt;load modules via CDN&lt;/A&gt;, TypeScript throws an error, saying there is no global variable named $argis.&lt;/P&gt;&lt;PRE&gt;error TS2339: Property '$arcgis' does not exist on type 'Window &amp;amp; typeof globalThis'.&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;How do I get TypeScript to recognize $arcgis?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I've figured out that $arcgis is defined in&amp;nbsp;"@arcgis/core-adapter". I can get Visual Studio Code to stop complaining if I add "@arcgis/core-adapter" to package.json, but tsc still throws the error.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// This gets Visual Studio Code to stop complaining, but not tsc.
const FeatureLayer = await window.$arcgis.import&amp;lt;typeof __esri.FeatureLayer&amp;gt;("@arcgis/core/layers/FeatureLayer.js");&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 03 Apr 2025 16:40:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1602411#M86811</guid>
      <dc:creator>JeffJacobson</dc:creator>
      <dc:date>2025-04-03T16:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: TypeScript errors when using $arcgis.import</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1602506#M86814</link>
      <description>&lt;P&gt;You can declare this on the global type in your app&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export declare global {
  // maybe this
  // var $arcgis: { import&amp;lt;T&amp;gt;?: (modules: string[]) =&amp;gt; Promise&amp;lt;T&amp;gt; | null };
  var $arcgis: { import?: (modules: string[]) =&amp;gt; Promise&amp;lt;unknown&amp;gt; | null };
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2025 20:02:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1602506#M86814</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2025-04-03T20:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: TypeScript errors when using $arcgis.import</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1603820#M86845</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I have created an improved type definition for &lt;FONT face="courier new,courier"&gt;$arcgis.import&lt;/FONT&gt; and &lt;A title="WSDOT-GIS/arcgis-core-helper on GitHub" href="https://github.com/WSDOT-GIS/arcgis-core-helper" target="_blank" rel="noopener"&gt;put it on GitHub&lt;/A&gt;.&lt;/STRONG&gt; It is &lt;A title="The Unlicense" href="https://unlicense.org/" target="_blank" rel="noopener"&gt;Unlicensed&lt;/A&gt;, so anyone can use it and incorporate it into their own code without asking for permission.&lt;/P&gt;&lt;P&gt;I used ChatGPT to help generate a script to dump a list of mappings, so developers using &lt;FONT face="courier new,courier"&gt;$arcgis.import&lt;/FONT&gt; no longer need to specify the type parameter.&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;I haven't yet packaged it and put it in a repository (e.g., NPM), but I think users can directly add the GitHub repo as a package to their project. (I haven't tested this. If that doesn't work, they can just copy the d.ts file into their own project.)&lt;/STRIKE&gt;&lt;/P&gt;&lt;H2&gt;Edit&lt;/H2&gt;&lt;UL&gt;&lt;LI&gt;I have since published it as an npm package:&amp;nbsp;&lt;A title="@wsdot/arcgis-core-helper package on NPM" href="https://www.npmjs.com/package/@wsdot/arcgis-core-helper" target="_blank" rel="noopener"&gt;@wsdot/arcgis-core-helper&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;I renamed the GitHub repo, so I have updated its link.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 06 Aug 2025 16:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-errors-when-using-arcgis-import/m-p/1603820#M86845</guid>
      <dc:creator>JeffJacobson</dc:creator>
      <dc:date>2025-08-06T16:23:29Z</dc:date>
    </item>
  </channel>
</rss>

