The ES Module FeatureSnappingLayerSource produces an incorrect typing error when setting SnappingOptions on Sketch:
this._layer = new GraphicsLayer();
this._mapView.map.add(this._layer);
this._sketchVM = new SketchViewModel({
view: this._mapView,
layer: this._layer,
snappingOptions: {
enabled: true,
featureSources: [{
layer: this._layer /** type error **/
}]
}
});
Type error:
SpoilerNo overload matches this call.
Overload 1 of 2, '(properties?: SketchViewModelProperties): SketchViewModel', gave the following error.
Type '{ layer: esri.GraphicsLayer; }' is not assignable to type 'FeatureSnappingLayerSourceProperties'.
Object literal may only specify known properties, and 'layer' does not exist in type 'FeatureSnappingLayerSourceProperties'.
Overload 2 of 2, '(properties?: SketchViewModelProperties): SketchViewModel', gave the following error.
Type '{ layer: esri.GraphicsLayer; }' is not assignable to type 'FeatureSnappingLayerSourceProperties'.
Object literal may only specify known properties, and 'layer' does not exist in type 'FeatureSnappingLayerSourceProperties'.ts(2769)
The error occurs because FeatureSnappingLayerSourceProperties type does not have a 'layer' property. The
same code above works with AMD which has no type checking. Works when adding TS ignore:
this._sketchVM = new SketchViewModel({
view: this._mapView,
layer: this._layer,
snappingOptions: {
enabled: true,
featureSources: [{
// @ts-ignore: Type definition bug
layer: this._layer
}]
}
});
Requesting this be fixed in a future release.