Feature.clone returns correct type.

This commit is contained in:
Simon Seyock
2021-08-06 10:05:19 +02:00
parent 4f38dd2c66
commit cebaa546b7

View File

@@ -144,17 +144,17 @@ class Feature extends BaseObject {
/** /**
* Clone this feature. If the original feature has a geometry it * Clone this feature. If the original feature has a geometry it
* is also cloned. The feature id is not set in the clone. * is also cloned. The feature id is not set in the clone.
* @return {Feature} The clone. * @return {Feature<Geometry>} The clone.
* @api * @api
*/ */
clone() { clone() {
const clone = new Feature( const clone = /** @type {Feature<Geometry>} */ (
this.hasProperties() ? this.getProperties() : null new Feature(this.hasProperties() ? this.getProperties() : null)
); );
clone.setGeometryName(this.getGeometryName()); clone.setGeometryName(this.getGeometryName());
const geometry = this.getGeometry(); const geometry = this.getGeometry();
if (geometry) { if (geometry) {
clone.setGeometry(geometry.clone()); clone.setGeometry(/** @type {Geometry} */ (geometry.clone()));
} }
const style = this.getStyle(); const style = this.getStyle();
if (style) { if (style) {