Select to view content in your preferred language

How to use jsdoc with @arcgis/core for typing help (for interface types)

68
0
Thursday
RyanSutcliffe
Frequent Contributor

In this post over here I asked how to get typing support within JavaScript for @arcgis/core classes and functions-- particularly with JSDoc style docstrings. 

That works for most items, but often I want to also import a type interface that is defined in the @ArcGIS/core/interfaces.d.ts file. For example that is where you would find an interface for something like HitTestResult, which is returned from the MapView's hitTest method. 

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. 

I want to do something like this:

 

 

 

 

const response /** @type {import("@arcgis/core/interfaces.d.ts").HitTestResult)}  */ = (
    await view.hitTest(event, options)
  );

 

 

 

 

 

Where I use JSDoc's casting approach although the above "@arcgis/core/interfaces.d.ts" approach is not recognized.

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. 

 

--
Saw this on the internet about type definition file types in javascript/JSDoc but not sure how to implement for my case.

Tags (3)
0 Kudos
0 Replies