Use generics to limit event types in on(), once() and un()

This commit is contained in:
Andreas Hocevar
2021-06-20 20:22:53 +02:00
parent cf7213c5cb
commit 018ad97f25
30 changed files with 49 additions and 7 deletions
+2
View File
@@ -38,6 +38,8 @@ import {clamp} from '../math.js';
* the options is set as a {@link module:ol/Object} property on the layer object, so
* is observable, and has get/set accessors.
*
* @template {string} EventTypes
* @extends BaseObject<EventTypes|'change:extent'|'change:maxResolution'|'change:maxZoom'|'change:minResolution'|'change:minZoom'|'change:opacity'|'change:visible'|'change:zIndex'>
* @api
*/
class BaseLayer extends BaseObject {
+1 -1
View File
@@ -45,7 +45,7 @@ import {assign} from '../obj.js';
* options means that `title` is observable, and has get/set accessors.
*
* @template {import("../source/Tile.js").default} TileSourceType
* @extends {Layer<TileSourceType>}
* @extends Layer<TileSourceType,'preload'|'useInterimTilesOnError'>
* @api
*/
class BaseTileLayer extends Layer {
+2 -1
View File
@@ -73,7 +73,8 @@ const Property = {
* options means that `title` is observable, and has get/set accessors.
*
* @template {import("../source/Vector.js").default|import("../source/VectorTile.js").default} VectorSourceType
* @extends {Layer<VectorSourceType>}
* @template {string} EventTypes
* @extends Layer<VectorSourceType,EventTypes>
* @api
*/
class BaseVectorLayer extends Layer {
+2
View File
@@ -85,6 +85,8 @@ import {listen, unlistenByKey} from '../events.js';
* @fires import("../render/Event.js").RenderEvent#postrender
*
* @template {import("../source/Source.js").default} SourceType
* @template {string} EventTypes
* @extends BaseLayer<EventTypes|'postrender'|'prerender'>
* @api
*/
class Layer extends BaseLayer {
+1 -1
View File
@@ -74,7 +74,7 @@ import {assign} from '../obj.js';
* options means that `title` is observable, and has get/set accessors.
*
* @param {Options} [opt_options] Options.
* @extends {BaseVectorLayer<import("../source/VectorTile.js").default>}
* @extends BaseVectorLayer<import("../source/VectorTile.js").default,'change:preload'|'change:useInterimTilesOnError'>
* @api
*/
class VectorTileLayer extends BaseVectorLayer {