Extend Graphics class in Typescript using ES modules

768
2
Jump to solution
09-23-2021 09:54 AM
Alexandre-Notos
New Contributor III

I want to create a new graphic type how ever the lastest https://developers.arcgis.com/javascript/latest/implementing-accessor/ instruction can't be follow because there is not ES module version.

Is there any guidance on how to proceed?

0 Kudos
1 Solution

Accepted Solutions
AndyGup
Esri Regular Contributor

HI @Alexandre-Notos, the API functionality is exactly the same and for the TypeScript code you'll need to swap out AMD module paths with ES modules paths and turn the commonjs require statements into import statements.

View solution in original post

0 Kudos
2 Replies
AndyGup
Esri Regular Contributor

HI @Alexandre-Notos, the API functionality is exactly the same and for the TypeScript code you'll need to swap out AMD module paths with ES modules paths and turn the commonjs require statements into import statements.

0 Kudos
Alexandre-Notos
New Contributor III

@AndyGup Thanks for the info. I manage to find the right path.

Now in the following code is it possible to change the 

properties?: any to 
properties: 
SegmentGraphicProperties
 
As the start point and end point are required?

import Graphic from "@arcgis/core/Graphic"; import { subclass, property } from "@arcgis/core/core/accessorSupport/decorators"; import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer"; @subclass("esri.core.Graphic.SegmentGraphic") export class SegmentGraphic extends Graphic{     @property()     startPoint: GraphicsLayer;     @property()     endPoint: Graphic;     constructor(properties?: any) {         super(properties);         this.startPoint = properties.startPoint;         this.endPoint = properties.endPoint;     } }

0 Kudos