There seems to be a simple solution that I am overlooking. I am currently working on a class that utilizes the Esri ArcGIS API, but I encounter a TypeScript error when importing type definitions from the arcgis-js-api
's d.ts
file. The error states "Cannot use 'new' with an expression whose type lacks a call or construct signature."
For example:
import * as IMap from 'esri/Map';
export class Foo {
bar: (Map: IMap) {
const map = new Map(); // <-- error here
}
}
Here are relevant excerpts from the d.ts
file:
declare namespace __esri {
/* snip */
interface Map extends Accessor, LayersMixin {
allLayers: Collection;
basemap: Basemap;
ground: Ground;
}
interface MapConstructor {
new(properties?: MapProperties): Map;
}
export const Map: MapConstructor;
/* snip */
}
declare module "esri/Map" {
import Map = __esri.Map;
export = Map;
}
Based on the type definition, everything appears correct. So, what could be causing TypeScript to believe that the IMap
type does not have a constructor?