Skip to content

Commit

Permalink
fix: types from dependency updates
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Mar 14, 2022
1 parent d18624e commit 8c79103
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
17 changes: 13 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Button/DigitizeButton/DigitizeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ class DigitizeButton extends React.Component<DigitizeButtonProps, DigitizeButton
map
} = this.props;

let digitizeLayer = digitizeLayerName ? MapUtil.getLayerByName(map, digitizeLayerName) : null;
let digitizeLayer = digitizeLayerName ? MapUtil.getLayerByName(map, digitizeLayerName) as OlLayerVector<OlSourceVector<OlGeometry>>: null;

if (!digitizeLayer) {
if (digitizeLayer == null) {
digitizeLayer = new OlLayerVector({
source: new OlSourceVector({
features: new OlCollection()
Expand All @@ -544,7 +544,7 @@ class DigitizeButton extends React.Component<DigitizeButtonProps, DigitizeButton

this._digitizeLayer = digitizeLayer;

this._digitizeFeatures = digitizeLayer.getSource().getFeaturesCollection();
this._digitizeFeatures = digitizeLayer.getSource()?.getFeaturesCollection() ?? null;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Button/MeasureButton/MeasureButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class MeasureButton extends React.Component<MeasureButtonProps> {
map
} = this.props;

let measureLayer = MapUtil.getLayerByName(map, measureLayerName);
let measureLayer = MapUtil.getLayerByName(map, measureLayerName) as OlLayerVector<OlSourceVector<OlGeometry>>;

if (!measureLayer) {
measureLayer = new OlLayerVector({
Expand Down
6 changes: 3 additions & 3 deletions src/Legend/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import _isEqual from 'lodash/isEqual';

import Logger from '@terrestris/base-util/dist/Logger';
import MapUtil from '@terrestris/ol-util/dist/MapUtil/MapUtil';
import OlBaseLayer from 'ol/layer/Base';

import { CSS_PREFIX } from '../constants';
import { WmsLayer } from '../Util/typeUtils';

export interface BaseProps {
/**
Expand All @@ -16,7 +16,7 @@ export interface BaseProps {
/**
* The layer you want to display the legend of.
*/
layer: OlBaseLayer;
layer: WmsLayer;
/**
* An object containing additional request params like "{HEIGHT: 400}" will
* be transformed to "&HEIGHT=400" an added to the GetLegendGraphic request.
Expand Down Expand Up @@ -105,7 +105,7 @@ export class Legend extends React.Component<LegendProps, LegendState> {
* @param layer The layer to get the legend graphic request for.
* @param extraParams The extra params.
*/
getLegendUrl(layer: OlBaseLayer, extraParams: any) {
getLegendUrl(layer: WmsLayer, extraParams: any) {
let legendUrl;

if (layer.get('legendUrl')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Util/DigitizeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class DigitizeUtil {
* @param map
*/
static getDigitizeLayer(map: OlMap): OlVectorLayer<OlSourceVector<Geometry>> {
let digitizeLayer = MapUtil.getLayerByName(map, DigitizeUtil.DIGITIZE_LAYER_NAME);
let digitizeLayer = MapUtil.getLayerByName(map, DigitizeUtil.DIGITIZE_LAYER_NAME) as OlVectorLayer<OlSourceVector>;

if (!digitizeLayer) {
digitizeLayer = new OlLayerVector({
Expand Down
2 changes: 1 addition & 1 deletion src/Util/typeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import OlTileWMS from 'ol/source/TileWMS';
import OlImageLayer from 'ol/layer/Image';
import OlTileLayer from 'ol/layer/Tile';

export type WmsLayer = OlImageLayer<OlImageWMS> | OlTileLayer<OlTileWMS>;
export type WmsLayer = OlImageLayer<OlImageWMS> | OlTileLayer<OlTileWMS> | OlLayer<OlImageWMS | OlTileWMS>;

export function isWmsLayer(layer: OlBaseLayer): layer is OlLayer<OlImageWMS | OlTileWMS, any> {
if (layer instanceof OlLayer) {
Expand Down

0 comments on commit 8c79103

Please sign in to comment.