jsapi-resources icon indicating copy to clipboard operation
jsapi-resources copied to clipboard

'type' does not exist in type 'SymbolProperties'

Open nbabel opened this issue 5 years ago • 9 comments

I am reporting an issue with

  • [x] TypeScript definitions
  • [ ] another resource in this repository

I'm getting a type error with Graphic. I've cloned this repo and added Graphic to the app.component.ts. When I add the following code I get a compilation error from Visual Studio Code "Type '{ type: string; color: number[]; outline: null; }' is not assignable to type 'SymbolProperties'. Object literal may only specify known properties, and 'type' does not exist in type 'SymbolProperties'.ts(2322)"

const extentGraphic = new Graphic({ geometry: null, symbol: { type: 'simple-fill', color: [0, 0, 0, 0.5], outline: null } });

The symbol property on Graphic should autocast to Symbol. Type is a valid property on symbol. https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html#properties-summary Is there an error in the 4.18 api or is there some sort of typescript error?

nbabel avatar Jan 07 '21 16:01 nbabel

Typescript doesn't support auto casting. Import SimpleFillSymbol and symbol: new SimpleFillSymbol(...).

COV-GIS avatar Jan 07 '21 16:01 COV-GIS

This worked at 4.16 and 4.17 using the arcgis webpack plugin. Any reason it wouldn't work now with 4.18 and @arcgis/core?

nbabel avatar Jan 07 '21 17:01 nbabel

I switched to TS at 4.13 and this is the first issue I ran into migrating from JS. Hard to say why it "worked" before but you should have been getting that error.

COV-GIS avatar Jan 07 '21 17:01 COV-GIS

Adding symbol: new SimpleFillSymbol(...) does resolve the error. Not sure why I'm just now coming across this error. Maybe something in the imports between the ArcGIS Webpack plugin and the esmodules of @arcgis/core is different. It seems like that should be highlighted better in the documentation about using typescript.

nbabel avatar Jan 07 '21 19:01 nbabel

We recently worked on support for this type of auto-casting in the typings, it should become available in the 4.19 (March) release.

jkieboom avatar Jan 11 '21 15:01 jkieboom

in arcgis-api-js 4.19.3,simple-fill type is not support yet

overcash597 avatar May 21 '21 01:05 overcash597

Hi @overcash597 that is correct, and thanks for everyone's patience on this. This issue is related to functionality that finally made it into TypeScript 4.3, and it just became a release candidate on May 12. Since we still need to verify this functionality and wait for TypeScript 4.3 to become final, we don't expect this to make the 4.20 release which is tentatively planned for the end of June.

In the meantime, in order to get your build to work you will need initialize new SimpleFillSymbol(), new SimpleLineSymbol() and new Color(). You'll have to extract all autocasted Classes and initialize them separately.

The 4.20 doc is also being updated to reflect this issue.

andygup avatar May 21 '21 15:05 andygup

thank for replay! waiting for the new one

overcash597 avatar May 24 '21 07:05 overcash597

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you need additional assistance please contact Esri Technical Support. Thank you for your contributions.

github-actions[bot] avatar Jul 22 '22 00:07 github-actions[bot]

This issue has been automatically closed due to inactivity. If you need additional assistance please contact Esri Technical Support.

github-actions[bot] avatar Aug 22 '22 00:08 github-actions[bot]