Throw when calling abstract methods; fix abstract return types

This commit is contained in:
ahocevar
2018-10-30 18:45:42 +01:00
parent 2adac0b3e7
commit 1cdd040c96
22 changed files with 273 additions and 85 deletions
+35 -11
View File
@@ -1,6 +1,7 @@
/**
* @module ol/style/Image
*/
import {abstract} from '../util.js';
/**
@@ -17,6 +18,7 @@
* A base class used for creating subclasses and not instantiated in
* apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and
* {@link module:ol/style/RegularShape~RegularShape}.
* @abstract
* @api
*/
class ImageStyle {
@@ -117,7 +119,9 @@ class ImageStyle {
* @abstract
* @return {Array<number>} Anchor.
*/
getAnchor() {}
getAnchor() {
return abstract();
}
/**
* Get the image element for the symbolizer.
@@ -125,46 +129,60 @@ class ImageStyle {
* @param {number} pixelRatio Pixel ratio.
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
*/
getImage(pixelRatio) {}
getImage(pixelRatio) {
return abstract();
}
/**
* @abstract
* @param {number} pixelRatio Pixel ratio.
* @return {HTMLCanvasElement|HTMLVideoElement|HTMLImageElement} Image element.
*/
getHitDetectionImage(pixelRatio) {}
getHitDetectionImage(pixelRatio) {
return abstract();
}
/**
* @abstract
* @return {import("../ImageState.js").default} Image state.
*/
getImageState() {}
getImageState() {
return abstract();
}
/**
* @abstract
* @return {import("../size.js").Size} Image size.
*/
getImageSize() {}
getImageSize() {
return abstract();
}
/**
* @abstract
* @return {import("../size.js").Size} Size of the hit-detection image.
*/
getHitDetectionImageSize() {}
getHitDetectionImageSize() {
return abstract();
}
/**
* Get the origin of the symbolizer.
* @abstract
* @return {Array<number>} Origin.
*/
getOrigin() {}
getOrigin() {
return abstract();
}
/**
* Get the size of the symbolizer (in pixels).
* @abstract
* @return {import("../size.js").Size} Size.
*/
getSize() {}
getSize() {
return abstract();
}
/**
* Set the opacity.
@@ -220,13 +238,17 @@ class ImageStyle {
* @return {import("../events.js").EventsKey|undefined} Listener key.
* @template T
*/
listenImageChange(listener, thisArg) {}
listenImageChange(listener, thisArg) {
return abstract();
}
/**
* Load not yet loaded URI.
* @abstract
*/
load() {}
load() {
abstract();
}
/**
* @abstract
@@ -234,7 +256,9 @@ class ImageStyle {
* @param {T} thisArg Value to use as `this` when executing `listener`.
* @template T
*/
unlistenImageChange(listener, thisArg) {}
unlistenImageChange(listener, thisArg) {
abstract();
}
}
export default ImageStyle;