How to use interface types with new ES modules

340
1
Jump to solution
04-22-2021 12:09 PM
RussellMGreen
New Contributor

What is the recommended way to use interfaces when using ES modules (@arcgis/core)?

For example, I have an Angular application that I have loaded:

import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer';
import Graphic from '@arcgis/core/Graphic'; 

How would I gain access to a type like MapViewProperties?

 

I've tried installing the @types/arcgis-js-api package in addition to @arcgis/core, but that seems like it would be overkill.

Example:

import ImageryLayer from '@arcgis/core/layers/ImageryLayer';
import GeoJSONLayer from '@arcgis/core/layers/GeoJSONLayer';
import Esri = __esri; // <--- used just for interfaces

const mapOptions: Esri.MapProperties = {...}; 

What's the recommended approach?

 

Thanks!

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor II

The @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 like this to use it in a short esri namespace.

View solution in original post

0 Kudos
1 Reply
ReneRubalcava
Frequent Contributor II

The @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 like this to use it in a short esri namespace.

0 Kudos