<?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: How to use interface types with new ES modules in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1050296#M72700</link>
    <description>&lt;P&gt;The&amp;nbsp;@arcgis/core package already comes with the typings, no need for extra installs. You can continue to use the __esri namespace or alias it in your own d.ts file &lt;A href="https://github.com/Esri/arcgis-js-cli/blob/master/templates/webpack/app/src/interfaces.d.ts#L1" target="_self"&gt;like this&lt;/A&gt; to use it in a short esri namespace.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Apr 2021 19:41:50 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2021-04-22T19:41:50Z</dc:date>
    <item>
      <title>How to use interface types with new ES modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1050261#M72699</link>
      <description>&lt;P&gt;What is the recommended way to use interfaces when using ES modules (@arcgis/core)?&lt;/P&gt;&lt;P&gt;For example, I have an Angular application that I have loaded:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer';
import Graphic from '@arcgis/core/Graphic'; &lt;/LI-CODE&gt;&lt;P&gt;How would I gain access to a type like &lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;MapViewProperties&lt;FONT color="#000000"&gt;?&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;SPAN&gt;&lt;FONT color="#000000"&gt;I've tried installing the&amp;nbsp;&lt;SPAN&gt;@types/arcgis-js-api package in addition to&amp;nbsp;@arcgis/core, but that seems like it would be overkill.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import ImageryLayer from '@arcgis/core/layers/ImageryLayer';
import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer';
import Esri = __esri; // &amp;lt;--- used just for interfaces

const mapOptions: Esri.MapProperties = {...}; &lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;What's the recommended approach?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 19:11:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1050261#M72699</guid>
      <dc:creator>RussellMGreen</dc:creator>
      <dc:date>2021-04-22T19:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use interface types with new ES modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1050296#M72700</link>
      <description>&lt;P&gt;The&amp;nbsp;@arcgis/core package already comes with the typings, no need for extra installs. You can continue to use the __esri namespace or alias it in your own d.ts file &lt;A href="https://github.com/Esri/arcgis-js-cli/blob/master/templates/webpack/app/src/interfaces.d.ts#L1" target="_self"&gt;like this&lt;/A&gt; to use it in a short esri namespace.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Apr 2021 19:41:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1050296#M72700</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-04-22T19:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use interface types with new ES modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1275303#M80741</link>
      <description>&lt;P&gt;Running into the same problem. My angular app complies fine, but then breaks on loading using the&lt;BR /&gt;&lt;SPAN&gt;"import esri = __esri" method.&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;&amp;nbsp;I would like to try your suggestion, but t&lt;/SPAN&gt;he link no longer works.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 14:59:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1275303#M80741</guid>
      <dc:creator>JonathanBorgia</dc:creator>
      <dc:date>2023-04-04T14:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use interface types with new ES modules</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1275315#M80742</link>
      <description>&lt;P&gt;The import alias should still work, but might break depending on the tsconfig.&lt;/P&gt;&lt;P&gt;With the latest TypeScript, it's recommended that you utilize &lt;A href="https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export" target="_self"&gt;type-only imports&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import type FeatureLayer from "@arcgis/core/layers/FeatureLayer";

export function doSomethingWithLayer(layer: FeatureLayer) {
  // super cool stuff
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to do something like a factory method, where you want to type the properties used for something, you can do something like this.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import FeatureLayer from "@arcgis/core/layers/FeatureLayer";

type LayerFactoryProps = InstanceType&amp;lt;typeof FeatureLayer&amp;gt;;
export function layerFactory(props: LayerFactoryProps) {
  // maybe add some defaults here
  // create layer
  const layer = new FeatureLayer(props);
  return layer;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally, I would recommend against using the __esri namespace, unless you really need it for things like the Event types, or watch/reactiveUtil handlers. Other than that, you should avoid it.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:17:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-interface-types-with-new-es-modules/m-p/1275315#M80742</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-04-04T15:17:34Z</dc:date>
    </item>
  </channel>
</rss>

