Coordinate Conversion reverseConvert type issue

354
2
11-28-2022 03:53 AM
Char10773g
New Contributor III

Hi, 

I am trying to follow this code snippet to add a new Format to the coordinate conversion widget. The problem I am having is that the reverseConvert property on the ConversionInfo type appears to be expecting a function with no arguments that does not return anything, but the example is passing a string and returning a Point.

The error is:

Type '(string: String) => Point' is not assignable to type '() => void'.

 

Has anyone come across this error before and found a workaround? 

2 Replies
Char10773g
New Contributor III

The example also uses the property spatialReference - which also appears to be not defined in the interface

Object literal may only specify known properties, and 'spatialReference' does not exist in type 'ConversionInfo'.

Any advice for implementing new formats/conversions much appreciated!

0 Kudos
Char10773g
New Contributor III

For anyone who is coming to this issue in the future - the reason for this issue is that the types are incorrectly defined in esri's interface.ts file. I have raised the issue with ESRI via premium support, and provided them with the correct type definition but incredibly they refuse to raise a bug to resolve it. I will post any workarounds if I come up with any.

For reference, this is the incorrect type definition currently in the interface file:

 /**
   * This object describes how a Format should be projected and formatted for display.
   *
   * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CoordinateConversion-support-Format.html#ConversionInfo)
   */
  export interface ConversionInfo extends Object {
    /**
     * A function that takes a point and returns a [position](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CoordinateConversion-support-Format.html#Position).
     *
     * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CoordinateConversion-support-Format.html#ConversionInfo)
     */
    convert(): void;
    /**
     * A function that takes a string and returns a Point.
     *
     * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-CoordinateConversion-support-Format.html#ConversionInfo)
     */
    reverseConvert(): void;
  }

 

0 Kudos