Hello, I'm using Visual Studio 2015 to try to create a widget for a web application and I'm having trouble getting started. I'm following the tutorial on the ArcGIS API for JavaScript website: TypeScript - Setting up your development environment | ArcGIS API for JavaScript 4.4 , but I get red squiggles under all the properties, causing the application to not compile. I think I installed the ArcGIS Typing correctly via npm. An image is attached. Any assistance would be greatly appreciated. Thank you.
Solved! Go to Solution.
I'm not completely sure that this is the issue, but I think this may have to do with how the JS API typings work with "autocasting." The signature for the basemap property is not string, it looks like:
interface BasemapProperties extends LoadableProperties {
baseLayers?: Collection;
id?: string;
loaded?: boolean;
portalItem?: PortalItemProperties;
referenceLayers?: Collection;
thumbnailUrl?: string;
title?: string;
}
This means that although a string is valid for a basemap in javascript, it's not valid in typescript. This issue discusses some workarounds: Typings for basemap not matching actual javascript · Issue #77 · Esri/jsapi-resources · GitHub
You could try passing in { id: "streets" } to the basemap property. It may accept that. You could also try one of the workarounds in that github issue.
What is the error? I'm not familiar with visual studio, but can you mouse over the underlined code to display the error?
Thanks for taking a look, Thomas. The attached image shows the error list.
I'm not completely sure that this is the issue, but I think this may have to do with how the JS API typings work with "autocasting." The signature for the basemap property is not string, it looks like:
interface BasemapProperties extends LoadableProperties {
baseLayers?: Collection;
id?: string;
loaded?: boolean;
portalItem?: PortalItemProperties;
referenceLayers?: Collection;
thumbnailUrl?: string;
title?: string;
}
This means that although a string is valid for a basemap in javascript, it's not valid in typescript. This issue discusses some workarounds: Typings for basemap not matching actual javascript · Issue #77 · Esri/jsapi-resources · GitHub
You could try passing in { id: "streets" } to the basemap property. It may accept that. You could also try one of the workarounds in that github issue.
Thank you, Thomas! The squiggles are all gone and the application compiled successfully. This is a good start. Thank you for your time!