Select to view content in your preferred language

Typescript: Are we supposed to use __esri to access types in the SDK?

314
2
02-26-2025 01:31 AM
ae
by
Frequent Contributor

Hi, 

In some cases it is not clear to me where I should get the types for using the SDK. For instance, if I want to type an object as being properties that can be used to define a Featurelayer, I cannot find this type in the SDK reference shown here: 

FeatureLayer | API Reference | ArcGIS Maps SDK for JavaScript 4.32 | Esri Developer 

However, I've seen people using the namespace "__esri" to access interfaces, and here I can find the interface __esri.FeatureLayerProperties which suits my needs.

Is it recommended to use interfaces and types from "__esri" or not? 

Tags (1)
2 Replies
JonathanDawe_BAS
Occasional Contributor

I've seen the esri development team recommend the usage of the __esri namespace in the past - I've even seen a recommendation to alias __esri to esri. 

I use it extensively it across all of my projects when working with the ArcGIS JS AP for the exact situations you describe. Its much simpler then using something like the ConstructorParameters utility typescript types! 

GeoGalvanic
Occasional Contributor

It's a good question. In the recent release ESRI notes that there is a module for accessing "Union Types". https://developers.arcgis.com/javascript/latest/release-notes/#new-union-types 

 

I'm hoping that module will continue to be expanded in the future (i.e. for MapView | SceneView and more). I also hope that other types/interfaces will be exposed in a public facing module in the future. 

 

I don't think there's anything particularly wrong with using __esri namespace at the moment, but since it's an internal namespace I would think that things could change in future releases that would require some code modifications without much or any notice.

0 Kudos