Use declare for leaflet defined fields

This commit is contained in:
James Lyne 2021-08-26 21:40:54 +01:00
parent 7fb843d618
commit ca8142cca8
13 changed files with 33 additions and 37 deletions

View File

@ -18,10 +18,11 @@ import {Map, DomUtil, MapOptions} from 'leaflet';
import LayerManager from "@/leaflet/layer/LayerManager"; import LayerManager from "@/leaflet/layer/LayerManager";
export default class LiveAtlasLeafletMap extends Map { export default class LiveAtlasLeafletMap extends Map {
declare _controlCorners: any;
declare _controlContainer?: HTMLElement;
declare _container?: HTMLElement;
private readonly _layerManager: LayerManager; private readonly _layerManager: LayerManager;
private _controlCorners: any;
private _controlContainer?: HTMLElement;
private _container?: HTMLElement;
constructor(element: string | HTMLElement, options?: MapOptions) { constructor(element: string | HTMLElement, options?: MapOptions) {
super(element, options); super(element, options);

View File

@ -22,8 +22,7 @@ import {watch} from "@vue/runtime-core";
import "@/assets/icons/chat.svg"; import "@/assets/icons/chat.svg";
export class ChatControl extends Control { export class ChatControl extends Control {
// @ts-ignore declare options: ControlOptions
options: ControlOptions
constructor(options: ControlOptions) { constructor(options: ControlOptions) {
super(options); super(options);

View File

@ -38,10 +38,9 @@ export interface ClockControlOptions extends ControlOptions {
} }
export class ClockControl extends Control { export class ClockControl extends Control {
// @ts-ignore declare options: ClockControlOptions;
options: ClockControlOptions; declare _container?: HTMLElement;
private _container?: HTMLElement;
private _sun?: HTMLElement; private _sun?: HTMLElement;
private _moon?: HTMLElement; private _moon?: HTMLElement;
private _clock?: HTMLElement; private _clock?: HTMLElement;

View File

@ -31,10 +31,9 @@ export interface CoordinatesControlOptions extends ControlOptions {
} }
export class CoordinatesControl extends Control { export class CoordinatesControl extends Control {
// @ts-ignore declare options: CoordinatesControlOptions;
options: CoordinatesControlOptions; declare _map ?: Map;
private _map ?: Map;
private _location?: Coordinate; private _location?: Coordinate;
private _locationChanged: boolean = false; private _locationChanged: boolean = false;
private readonly _coordsContainer: HTMLSpanElement; private readonly _coordsContainer: HTMLSpanElement;

View File

@ -25,8 +25,7 @@ import {notify} from "@kyvg/vue3-notification";
import {computed} from "@vue/runtime-core"; import {computed} from "@vue/runtime-core";
export class LinkControl extends Control { export class LinkControl extends Control {
// @ts-ignore declare options: ControlOptions
options: ControlOptions
constructor(options: ControlOptions) { constructor(options: ControlOptions) {
super(options); super(options);

View File

@ -32,15 +32,16 @@ import Layers = Control.Layers;
const store = useStore(); const store = useStore();
export class LiveAtlasLayerControl extends Control.Layers { export class LiveAtlasLayerControl extends Control.Layers {
declare _map ?: LeafletMap;
declare _overlaysList?: HTMLElement;
declare _baseLayersList?: HTMLElement;
declare _layerControlInputs?: HTMLElement[];
declare _container?: HTMLElement;
declare _section?: HTMLElement;
declare _separator?: HTMLElement;
private _layersButton?: HTMLElement; private _layersButton?: HTMLElement;
private _map ?: LeafletMap;
private _overlaysList?: HTMLElement;
private _baseLayersList?: HTMLElement;
private _layerControlInputs?: HTMLElement[];
private _layerPositions: Map<Layer, number>; private _layerPositions: Map<Layer, number>;
private _container?: HTMLElement;
private _section?: HTMLElement;
private _separator?: HTMLElement;
private visible: boolean = false; private visible: boolean = false;
constructor(baseLayers?: LayersObject, overlays?: LayersObject, options?: LayersOptions) { constructor(baseLayers?: LayersObject, overlays?: LayersObject, options?: LayersOptions) {

View File

@ -38,12 +38,11 @@ export interface LoadingControlOptions extends ControlOptions {
} }
export class LoadingControl extends Control { export class LoadingControl extends Control {
// @ts-ignore declare options: LoadingControlOptions;
options: LoadingControlOptions;
_dataLoaders: Set<number> = new Set(); private _dataLoaders: Set<number> = new Set();
_loadingIndicator: HTMLDivElement; private readonly _loadingIndicator: HTMLDivElement;
_delayIndicatorTimeout?: number; private _delayIndicatorTimeout?: number;
constructor(options: LoadingControlOptions) { constructor(options: LoadingControlOptions) {
super(options); super(options);

View File

@ -26,8 +26,7 @@ export interface LogoControlOptions extends ControlOptions {
} }
export class LogoControl extends Control { export class LogoControl extends Control {
// @ts-ignore declare options: LogoControlOptions;
options: LogoControlOptions;
constructor(options: LogoControlOptions) { constructor(options: LogoControlOptions) {
super(options); super(options);

View File

@ -45,8 +45,7 @@ export class GenericIcon extends DivIcon {
className: '', className: '',
}; };
// @ts-ignore declare options: GenericIconOptions;
options: GenericIconOptions;
private _image?: HTMLImageElement; private _image?: HTMLImageElement;
private _label?: HTMLSpanElement; private _label?: HTMLSpanElement;

View File

@ -49,6 +49,8 @@ export interface PlayerIconOptions extends MarkerOptions {
} }
export class PlayerIcon extends DivIcon { export class PlayerIcon extends DivIcon {
declare options: PlayerIconOptions;
private readonly _player: LiveAtlasPlayer; private readonly _player: LiveAtlasPlayer;
private _container?: HTMLDivElement; private _container?: HTMLDivElement;
private _playerImage?: HTMLImageElement; private _playerImage?: HTMLImageElement;
@ -62,9 +64,6 @@ export class PlayerIcon extends DivIcon {
private _playerArmor?: HTMLDivElement; private _playerArmor?: HTMLDivElement;
private _playerArmorBar?: HTMLDivElement; private _playerArmorBar?: HTMLDivElement;
// @ts-ignore
options: PlayerIconOptions;
constructor(player: LiveAtlasPlayer, options: PlayerIconOptions) { constructor(player: LiveAtlasPlayer, options: PlayerIconOptions) {
super(options); super(options);
this._player = player; this._player = player;

View File

@ -28,11 +28,11 @@ export interface LiveAtlasLayerGroupOptions extends LayerOptions {
} }
export default class LiveAtlasLayerGroup extends LayerGroup { export default class LiveAtlasLayerGroup extends LayerGroup {
// @ts-ignore declare options: LiveAtlasLayerGroupOptions;
options: LiveAtlasLayerGroupOptions; declare _layers: any;
private _zoomLimitedLayers: Set<Layer>; //Layers which are zoom limited and should be checked on zoom private _zoomLimitedLayers: Set<Layer>; //Layers which are zoom limited and should be checked on zoom
_layers: any; private _markerPane?: HTMLElement;
_markerPane?: HTMLElement;
private _zoomEndCallback = () => this._updateLayerVisibility(); private _zoomEndCallback = () => this._updateLayerVisibility();

View File

@ -26,6 +26,8 @@ export interface PlayerMarkerOptions extends MarkerOptions {
} }
export class PlayerMarker extends Marker { export class PlayerMarker extends Marker {
declare options: PlayerMarkerOptions;
private _player: LiveAtlasPlayer; private _player: LiveAtlasPlayer;
constructor(player: LiveAtlasPlayer, options: PlayerMarkerOptions) { constructor(player: LiveAtlasPlayer, options: PlayerMarkerOptions) {

View File

@ -26,9 +26,9 @@ export interface LiveAtlasTileLayerOptions extends TileLayerOptions {
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
export abstract class LiveAtlasTileLayer extends TileLayer { export abstract class LiveAtlasTileLayer extends TileLayer {
protected _mapSettings: LiveAtlasMapDefinition;
declare options: LiveAtlasTileLayerOptions; declare options: LiveAtlasTileLayerOptions;
protected _mapSettings: LiveAtlasMapDefinition;
private readonly tileTemplate: LiveAtlasTileElement; private readonly tileTemplate: LiveAtlasTileElement;
protected readonly loadQueue: LiveAtlasTileElement[] = []; protected readonly loadQueue: LiveAtlasTileElement[] = [];
private readonly loadingTiles: Set<LiveAtlasTileElement> = Object.seal(new Set()); private readonly loadingTiles: Set<LiveAtlasTileElement> = Object.seal(new Set());