Hi everyone in the Community.
I'm developing an Angular application using Typescript and ES modules syntax, but I'm facing a problem when I try to define some ArcGIS objects taking source from sample API application on Esri website.
For example the following code fails:
import Point from '@arcgis/core/geometry/Point';
...
const point: Point = {
//Create a point
type: 'point',
longitude: 12.600913,
latitude: 42.55151,
};
according to following pages on API documentation:
https://developers.arcgis.com/javascript/latest/add-a-point-line-and-polygon/
https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html
but just at editing time I got this error:
error TS2740: Type '{ type: "point"; longitude: number; latitude: number; }' is
missing the following properties from type 'Point': m, x, y, z, and 21 more.
Same behaviour occurs if I define in different ways the object.
May any of you explain what I'm making wrong and how to solve it?
Thanks in advance and best regards.
Solved! Go to Solution.
Typescript doesn't allow for autocasting, which is what's being used in line 7. To create a point, you'll have to use something like
const point: Point = new Point({
longitude: 12.600913,
latitude: 42.55151,
etc.
});
Typescript doesn't allow for autocasting, which is what's being used in line 7. To create a point, you'll have to use something like
const point: Point = new Point({
longitude: 12.600913,
latitude: 42.55151,
etc.
});