The TypeScript declaration file for the ArcGIS API for JavaScript contains type information specific for the API. You can learn more about how to install this file from the TypeScript set up guide page or on GitHub.
The version 4.6 introduces several improvements:
The documentation also includes a link to directly open the API reference at the relevant page.
const map = new WebMap({ // autocasts to a Basemap object basemap: "topo", layers: [ new FeatureLayer({ // autocasts to a PopupTemplate object popupTemplate: { content: "{*}" } }) ] });
const symbol = new SimpleFillSymbol({ // autocasts to a Color object color: "red", // autocasts to a SimpleLineSymbol object outline: { style: "solid" } });
import { Geometry } from "esri/geometry"; function logGeometry(geometry: geometry): void { // Geometry is a union of all the geometries // discriminate on the 'type' property if (geometry.type === "point") { // new at 4.6, the compiler knows the geometry is a Point instance console.log("point coords: ", geometry.x, geometry.y, geometry.z); } else { // the compiler knows the geometry must be a `Extent | Polygon | Multipoint | Polyline` console.log("The value is a geometry, but isn't a point.") } }
We hope these improvements will make you more productive in your application development.
Article Discussion: