From 90f50d98e7b14d50b61f73caa934474205b988c7 Mon Sep 17 00:00:00 2001 From: HarelM Date: Sun, 24 Dec 2023 00:42:02 +0200 Subject: [PATCH] Fix more types, migrate two more files --- package-lock.json | 10 ++ package.json | 1 + src/components/Block.tsx | 2 +- src/components/FieldComment.tsx | 4 +- src/components/FieldFunction.tsx | 2 +- src/components/FieldId.tsx | 4 +- src/components/FieldMaxZoom.tsx | 4 +- src/components/FieldMinZoom.tsx | 2 +- src/components/FieldSource.tsx | 4 +- src/components/FieldSourceLayer.tsx | 6 +- src/components/FieldType.tsx | 4 +- .../{FilterEditor.jsx => FilterEditor.tsx} | 73 +++++++------- src/components/InputAutocomplete.tsx | 2 +- src/components/InputSelect.tsx | 2 +- .../{LayerEditor.jsx => LayerEditor.tsx} | 97 ++++++++++--------- src/components/LayerEditorGroup.tsx | 2 +- src/components/PropertyGroup.tsx | 2 +- src/components/SingleFilterEditor.tsx | 2 +- src/components/_DataProperty.tsx | 2 +- src/components/_ExpressionProperty.tsx | 5 +- src/components/_FieldId.tsx | 2 +- src/components/_FieldMaxZoom.tsx | 2 +- src/components/_FieldMinZoom.tsx | 2 +- src/components/_FieldSource.tsx | 2 +- src/components/_FieldType.tsx | 2 +- src/components/_SpecProperty.tsx | 2 +- src/components/_ZoomProperty.tsx | 2 +- src/libs/layer.ts | 2 +- 28 files changed, 136 insertions(+), 110 deletions(-) rename src/components/{FilterEditor.jsx => FilterEditor.tsx} (73%) rename src/components/{LayerEditor.jsx => LayerEditor.tsx} (77%) diff --git a/package-lock.json b/package-lock.json index 40f20ada..2849aa14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,6 +75,7 @@ "@types/lodash.isequal": "^4.5.8", "@types/lodash.throttle": "^4.1.9", "@types/react": "^16.14.52", + "@types/react-aria-menubutton": "^6.2.13", "@types/react-aria-modal": "^4.0.9", "@types/react-autocomplete": "^1.8.9", "@types/react-collapse": "^5.0.4", @@ -4889,6 +4890,15 @@ "csstype": "^3.0.2" } }, + "node_modules/@types/react-aria-menubutton": { + "version": "6.2.13", + "resolved": "https://registry.npmjs.org/@types/react-aria-menubutton/-/react-aria-menubutton-6.2.13.tgz", + "integrity": "sha512-olSjeIzNzn0KrbShOmBwchHS++khDXBYFTO2U802o8LDHANLms7zUsJhdecfqFpwdFMHxFiMMlCn2nJNCEHWlQ==", + "dev": true, + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/react-aria-modal": { "version": "4.0.9", "resolved": "https://registry.npmjs.org/@types/react-aria-modal/-/react-aria-modal-4.0.9.tgz", diff --git a/package.json b/package.json index eea99ee4..a649d55a 100644 --- a/package.json +++ b/package.json @@ -104,6 +104,7 @@ "@types/lodash.isequal": "^4.5.8", "@types/lodash.throttle": "^4.1.9", "@types/react": "^16.14.52", + "@types/react-aria-menubutton": "^6.2.13", "@types/react-aria-modal": "^4.0.9", "@types/react-autocomplete": "^1.8.9", "@types/react-collapse": "^5.0.4", diff --git a/src/components/Block.tsx b/src/components/Block.tsx index d7fe3709..8aaa621a 100644 --- a/src/components/Block.tsx +++ b/src/components/Block.tsx @@ -12,7 +12,7 @@ type BlockProps = { onChange?(...args: unknown[]): unknown fieldSpec?: object wideMode?: boolean - error?: unknown[] + error?: {message: string} }; type BlockState = { diff --git a/src/components/FieldComment.tsx b/src/components/FieldComment.tsx index a455d096..5bf06b64 100644 --- a/src/components/FieldComment.tsx +++ b/src/components/FieldComment.tsx @@ -5,7 +5,8 @@ import InputString from './InputString' type FieldCommentProps = { value?: string - onChange(...args: unknown[]): unknown + onChange(value: string | undefined): unknown + error: {message: string} }; export default class FieldComment extends React.Component { @@ -18,6 +19,7 @@ export default class FieldComment extends React.Component { label={"Comments"} fieldSpec={fieldSpec} data-wd-key="layer-comment" + error={this.props.error} > { diff --git a/src/components/FieldMaxZoom.tsx b/src/components/FieldMaxZoom.tsx index 1ebefc8c..69f20eaf 100644 --- a/src/components/FieldMaxZoom.tsx +++ b/src/components/FieldMaxZoom.tsx @@ -6,8 +6,8 @@ import InputNumber from './InputNumber' type FieldMaxZoomProps = { value?: number - onChange(...args: unknown[]): unknown - error?: unknown[] + onChange(value: number | undefined): unknown + error?: {message: string} }; export default class FieldMaxZoom extends React.Component { diff --git a/src/components/FieldMinZoom.tsx b/src/components/FieldMinZoom.tsx index a3a7a759..f61b0a4a 100644 --- a/src/components/FieldMinZoom.tsx +++ b/src/components/FieldMinZoom.tsx @@ -7,7 +7,7 @@ import InputNumber from './InputNumber' type FieldMinZoomProps = { value?: number onChange(...args: unknown[]): unknown - error?: unknown[] + error?: {message: string} }; export default class FieldMinZoom extends React.Component { diff --git a/src/components/FieldSource.tsx b/src/components/FieldSource.tsx index c20e9eae..a7dd82da 100644 --- a/src/components/FieldSource.tsx +++ b/src/components/FieldSource.tsx @@ -7,9 +7,9 @@ import InputAutocomplete from './InputAutocomplete' type FieldSourceProps = { value?: string wdKey?: string - onChange?(...args: unknown[]): unknown + onChange?(value: string| undefined): unknown sourceIds?: unknown[] - error?: unknown[] + error?: {message: string} }; export default class FieldSource extends React.Component { diff --git a/src/components/FieldSourceLayer.tsx b/src/components/FieldSourceLayer.tsx index 6bc056c8..25e42806 100644 --- a/src/components/FieldSourceLayer.tsx +++ b/src/components/FieldSourceLayer.tsx @@ -9,6 +9,7 @@ type FieldSourceLayerProps = { onChange?(...args: unknown[]): unknown sourceLayerIds?: unknown[] isFixed?: boolean + error?: {message: string} }; export default class FieldSourceLayer extends React.Component { @@ -19,8 +20,11 @@ export default class FieldSourceLayer extends React.Component = 0 } -function hasNestedCombiningFilter(filter) { +function hasNestedCombiningFilter(filter: LegacyFilterSpecification | ExpressionSpecification) { if(hasCombiningFilter(filter)) { - const combinedFilters = filter.slice(1) - return filter.slice(1).map(f => hasCombiningFilter(f)).filter(f => f == true).length > 0 + return filter.slice(1).map(f => hasCombiningFilter(f as any)).filter(f => f == true).length > 0 } return false } -export default class FilterEditor extends React.Component { - static propTypes = { - /** Properties of the vector layer and the available fields */ - properties: PropTypes.object, - filter: PropTypes.array, - errors: PropTypes.object, - onChange: PropTypes.func.isRequired, - } +type FilterEditorProps = { + /** Properties of the vector layer and the available fields */ + properties?: {[key:string]: any} + filter?: any[] + errors?: {[key:string]: any} + onChange(value: LegacyFilterSpecification | ExpressionSpecification): unknown +}; +type FilterEditorState = { + showDoc: boolean + displaySimpleFilter: boolean + valueIsSimpleFilter?: boolean +}; + +export default class FilterEditor extends React.Component { static defaultProps = { filter: ["all"], } - constructor (props) { - super(); + constructor (props: FilterEditorProps) { + super(props); this.state = { showDoc: false, displaySimpleFilter: checkIfSimpleFilter(combiningFilter(props)), @@ -111,25 +115,25 @@ export default class FilterEditor extends React.Component { } // Convert filter to combining filter - onFilterPartChanged(filterIdx, newPart) { - const newFilter = combiningFilter(this.props).slice(0) + onFilterPartChanged(filterIdx: number, newPart: any[]) { + const newFilter = combiningFilter(this.props).slice(0) as LegacyFilterSpecification | ExpressionSpecification newFilter[filterIdx] = newPart this.props.onChange(newFilter) } - deleteFilterItem(filterIdx) { - const newFilter = combiningFilter(this.props).slice(0) + deleteFilterItem(filterIdx: number) { + const newFilter = combiningFilter(this.props).slice(0) as LegacyFilterSpecification | ExpressionSpecification newFilter.splice(filterIdx + 1, 1) this.props.onChange(newFilter) } addFilterItem = () => { - const newFilterItem = combiningFilter(this.props).slice(0) - newFilterItem.push(['==', 'name', '']) + const newFilterItem = combiningFilter(this.props).slice(0) as LegacyFilterSpecification | ExpressionSpecification + (newFilterItem as any[]).push(['==', 'name', '']) this.props.onChange(newFilterItem) } - onToggleDoc = (val) => { + onToggleDoc = (val: boolean) => { this.setState({ showDoc: val }); @@ -149,8 +153,7 @@ export default class FilterEditor extends React.Component { }) } - static getDerivedStateFromProps (props, currentState) { - const {filter} = props; + static getDerivedStateFromProps(props: FilterEditorProps, currentState: FilterEditorState) { const displaySimpleFilter = checkIfSimpleFilter(combiningFilter(props)); // Upgrade but never downgrade @@ -178,7 +181,7 @@ export default class FilterEditor extends React.Component { const fieldSpec={ doc: latest.layer.filter.doc + " Combine multiple filters together by using a compound filter." }; - const defaultFilter = ["all"]; + const defaultFilter = ["all"] as LegacyFilterSpecification | ExpressionSpecification; const isNestedCombiningFilter = displaySimpleFilter && hasNestedCombiningFilter(combiningFilter(this.props)); @@ -201,7 +204,7 @@ export default class FilterEditor extends React.Component { else if (displaySimpleFilter) { const filter = combiningFilter(this.props); let combiningOp = filter[0]; - let filters = filter.slice(1) + let filters = filter.slice(1) as (LegacyFilterSpecification | ExpressionSpecification)[]; const actions = (
@@ -218,7 +221,7 @@ export default class FilterEditor extends React.Component { ); const editorBlocks = filters.map((f, idx) => { - const error = errors[`filter[${idx+1}]`]; + const error = errors![`filter[${idx+1}]`]; return (
@@ -247,7 +250,7 @@ export default class FilterEditor extends React.Component { > this.onFilterPartChanged(0, v)} options={[["all", "every filter matches"], ["none", "no filter matches"], ["any", "any filter matches"]]} /> diff --git a/src/components/InputAutocomplete.tsx b/src/components/InputAutocomplete.tsx index fabaa16f..4665fa8a 100644 --- a/src/components/InputAutocomplete.tsx +++ b/src/components/InputAutocomplete.tsx @@ -8,7 +8,7 @@ const MAX_HEIGHT = 140; export type InputAutocompleteProps = { value?: string options: any[] - onChange(...args: unknown[]): unknown + onChange(value: string | undefined): unknown keepMenuWithinWindowBounds?: boolean 'aria-label'?: string }; diff --git a/src/components/InputSelect.tsx b/src/components/InputSelect.tsx index 53b627f3..039d03ee 100644 --- a/src/components/InputSelect.tsx +++ b/src/components/InputSelect.tsx @@ -5,7 +5,7 @@ export type InputSelectProps = { "data-wd-key"?: string options: [string, any][] | string[] style?: object - onChange(value: string): unknown + onChange(value: string | [string, any]): unknown title?: string 'aria-label'?: string }; diff --git a/src/components/LayerEditor.jsx b/src/components/LayerEditor.tsx similarity index 77% rename from src/components/LayerEditor.jsx rename to src/components/LayerEditor.tsx index 075681ff..ac4d2aa7 100644 --- a/src/components/LayerEditor.jsx +++ b/src/components/LayerEditor.tsx @@ -1,6 +1,8 @@ import React from 'react' import PropTypes from 'prop-types' import { Wrapper, Button, Menu, MenuItem } from 'react-aria-menubutton' +import {Accordion} from 'react-accessible-accordion'; +import {MdMoreVert} from 'react-icons/md' import FieldJson from './FieldJson' import FilterEditor from './FilterEditor' @@ -13,20 +15,18 @@ import FieldMaxZoom from './FieldMaxZoom' import FieldComment from './FieldComment' import FieldSource from './FieldSource' import FieldSourceLayer from './FieldSourceLayer' -import {Accordion} from 'react-accessible-accordion'; - -import {MdMoreVert} from 'react-icons/md' - import { changeType, changeProperty } from '../libs/layer' import layout from '../config/layout.json' import {formatLayerId} from '../util/format'; +import { SourceSpecification } from '@maplibre/maplibre-gl-style-spec'; +import { BackgroundLayerSpecification, LayerSpecification } from 'maplibre-gl'; -function getLayoutForType (type) { +function getLayoutForType(type: LayerSpecification["type"]) { return layout[type] ? layout[type] : layout.invalid; } -function layoutGroups(layerType) { +function layoutGroups(layerType: LayerSpecification["type"]): {title: string, type: string, fields?: string[]}[] { const layerGroup = { title: 'Layer', type: 'layer' @@ -44,25 +44,29 @@ function layoutGroups(layerType) { .concat([editorGroup]) } -/** Layer editor supporting multiple types of layers. */ -export default class LayerEditor extends React.Component { - static propTypes = { - layer: PropTypes.object.isRequired, - sources: PropTypes.object, - vectorLayers: PropTypes.object, - spec: PropTypes.object.isRequired, - onLayerChanged: PropTypes.func, - onLayerIdChange: PropTypes.func, - onMoveLayer: PropTypes.func, - onLayerDestroy: PropTypes.func, - onLayerCopy: PropTypes.func, - onLayerVisibilityToggle: PropTypes.func, - isFirstLayer: PropTypes.bool, - isLastLayer: PropTypes.bool, - layerIndex: PropTypes.number, - errors: PropTypes.array, - } +type LayerEditorProps = { + layer: LayerSpecification + sources?: SourceSpecification + vectorLayers: {[key: string]: any} + spec: object + onLayerChanged(...args: unknown[]): unknown + onLayerIdChange(...args: unknown[]): unknown + onMoveLayer(...args: unknown[]): unknown + onLayerDestroy(...args: unknown[]): unknown + onLayerCopy(...args: unknown[]): unknown + onLayerVisibilityToggle(...args: unknown[]): unknown + isFirstLayer?: boolean + isLastLayer?: boolean + layerIndex: number + errors?: any[] +}; +type LayerEditorState = { + editorGroups: {[keys:string]: boolean} +}; + +/** Layer editor supporting multiple types of layers. */ +export default class LayerEditor extends React.Component { static defaultProps = { onLayerChanged: () => {}, onLayerIdChange: () => {}, @@ -73,11 +77,11 @@ export default class LayerEditor extends React.Component { reactIconBase: PropTypes.object } - constructor(props) { + constructor(props: LayerEditorProps) { super(props) //TODO: Clean this up and refactor into function - const editorGroups = {} + const editorGroups: {[keys:string]: boolean} = {} layoutGroups(this.props.layer.type).forEach(group => { editorGroups[group.title] = true }) @@ -85,7 +89,7 @@ export default class LayerEditor extends React.Component { this.state = { editorGroups } } - static getDerivedStateFromProps(props, state) { + static getDerivedStateFromProps(props: LayerEditorProps, state: LayerEditorState) { const additionalGroups = { ...state.editorGroups } getLayoutForType(props.layer.type).groups.forEach(group => { @@ -108,14 +112,14 @@ export default class LayerEditor extends React.Component { } } - changeProperty(group, property, newValue) { + changeProperty(group: keyof LayerSpecification | null, property: string, newValue: any) { this.props.onLayerChanged( this.props.layerIndex, changeProperty(this.props.layer, group, property, newValue) ) } - onGroupToggle(groupTitle, active) { + onGroupToggle(groupTitle: string, active: boolean) { const changedActiveGroups = { ...this.state.editorGroups, [groupTitle]: active, @@ -125,15 +129,15 @@ export default class LayerEditor extends React.Component { }) } - renderGroupType(type, fields) { + renderGroupType(type: string, fields?: string[]): JSX.Element { let comment = "" if(this.props.layer.metadata) { - comment = this.props.layer.metadata['maputnik:comment'] + comment = (this.props.layer.metadata as any)['maputnik:comment'] } const {errors, layerIndex} = this.props; - const errorData = {}; - errors.forEach(error => { + const errorData: {[key in LayerSpecification as string]: {message: string}} = {}; + errors!.forEach(error => { if ( error.parsed && error.parsed.type === "layer" && @@ -146,8 +150,8 @@ export default class LayerEditor extends React.Component { }) let sourceLayerIds; - if(this.props.sources.hasOwnProperty(this.props.layer.source)) { - sourceLayerIds = this.props.sources[this.props.layer.source].layers; + if(this.props.sources?.hasOwnProperty((this.props.layer as Exclude).source)) { + sourceLayerIds = (this.props.sources as any)[(this.props.layer as any).source].layers; } switch(type) { @@ -169,7 +173,7 @@ export default class LayerEditor extends React.Component { /> {this.props.layer.type !== 'background' && this.changeProperty(null, 'source', v)} /> @@ -178,7 +182,7 @@ export default class LayerEditor extends React.Component { this.changeProperty(null, 'source-layer', v)} /> } @@ -202,8 +206,8 @@ export default class LayerEditor extends React.Component {
this.changeProperty(null, 'filter', f)} />
@@ -212,7 +216,7 @@ export default class LayerEditor extends React.Component { return @@ -226,10 +230,11 @@ export default class LayerEditor extends React.Component { ); }} /> + default: return <> } } - moveLayer(offset) { + moveLayer(offset: number) { this.props.onMoveLayer({ oldIndex: this.props.layerIndex, newIndex: this.props.layerIndex+offset @@ -237,7 +242,7 @@ export default class LayerEditor extends React.Component { } render() { - const groupIds = []; + const groupIds: string[] = []; const layerType = this.props.layer.type const groups = layoutGroups(layerType).filter(group => { return !(layerType === 'background' && group.type === 'source') @@ -258,7 +263,7 @@ export default class LayerEditor extends React.Component { const layout = this.props.layer.layout || {} - const items = { + const items: {[key: string]: {text: string, handler: () => void, disabled?: boolean}} = { delete: { text: "Delete", handler: () => this.props.onLayerDestroy(this.props.layerIndex) @@ -285,8 +290,8 @@ export default class LayerEditor extends React.Component { } } - function handleSelection(id, event) { - event.stopPropagation; + function handleSelection(id: string, event: React.SyntheticEvent) { + event.stopPropagation(); items[id].handler(); } @@ -310,7 +315,7 @@ export default class LayerEditor extends React.Component {
    - {Object.keys(items).map((id, idx) => { + {Object.keys(items).map((id) => { const item = items[id]; return
  • diff --git a/src/components/LayerEditorGroup.tsx b/src/components/LayerEditorGroup.tsx index 888f8d9b..fe4ae5af 100644 --- a/src/components/LayerEditorGroup.tsx +++ b/src/components/LayerEditorGroup.tsx @@ -18,7 +18,7 @@ type LayerEditorGroupProps = { title: string isActive: boolean children: React.ReactElement - onActiveToggle(...args: unknown[]): unknown + onActiveToggle(active: boolean): unknown }; diff --git a/src/components/PropertyGroup.tsx b/src/components/PropertyGroup.tsx index 1a328c77..2f4c7989 100644 --- a/src/components/PropertyGroup.tsx +++ b/src/components/PropertyGroup.tsx @@ -39,7 +39,7 @@ type PropertyGroupProps = { groupFields: string[] onChange(...args: unknown[]): unknown spec: any - errors?: unknown[] + errors?: {[key: string]: {message: string}} }; export default class PropertyGroup extends React.Component { diff --git a/src/components/SingleFilterEditor.tsx b/src/components/SingleFilterEditor.tsx index 63661a60..1de9ddbc 100644 --- a/src/components/SingleFilterEditor.tsx +++ b/src/components/SingleFilterEditor.tsx @@ -36,7 +36,7 @@ function parseFilter(v: string | boolean | number) { type SingleFilterEditorProps = { filter: any[] - onChange(...args: unknown[]): unknown + onChange(filter: any[]): unknown properties?: {[key: string]: string} }; diff --git a/src/components/_DataProperty.tsx b/src/components/_DataProperty.tsx index d292c6b4..7144e74f 100644 --- a/src/components/_DataProperty.tsx +++ b/src/components/_DataProperty.tsx @@ -288,7 +288,7 @@ export default class DataProperty extends React.Component this.changeDataType(propVal)} + onChange={(propVal: string) => this.changeDataType(propVal)} title={"Select a type of data scale (default is 'categorical')."} options={this.getDataFunctionTypes(this.props.fieldSpec)} /> diff --git a/src/components/_ExpressionProperty.tsx b/src/components/_ExpressionProperty.tsx index fbafdcfd..43dd77dc 100644 --- a/src/components/_ExpressionProperty.tsx +++ b/src/components/_ExpressionProperty.tsx @@ -14,7 +14,7 @@ type ExpressionPropertyProps = { fieldType?: string fieldSpec?: object value?: any - errors?: {[key: string]: any} + errors?: {[key: string]: {message: string}} onChange?(...args: unknown[]): unknown onUndo?(...args: unknown[]): unknown canUndo?(...args: unknown[]): unknown @@ -109,7 +109,8 @@ export default class ExpressionProperty extends React.Component { diff --git a/src/components/_FieldMaxZoom.tsx b/src/components/_FieldMaxZoom.tsx index 58f2b09f..2499bb85 100644 --- a/src/components/_FieldMaxZoom.tsx +++ b/src/components/_FieldMaxZoom.tsx @@ -7,7 +7,7 @@ import FieldNumber from './FieldNumber' type BlockMaxZoomProps = { value?: number onChange(...args: unknown[]): unknown - error?: unknown[] + error?: {message: string} }; export default class BlockMaxZoom extends React.Component { diff --git a/src/components/_FieldMinZoom.tsx b/src/components/_FieldMinZoom.tsx index f3edeafd..3b48b5c8 100644 --- a/src/components/_FieldMinZoom.tsx +++ b/src/components/_FieldMinZoom.tsx @@ -7,7 +7,7 @@ import FieldNumber from './FieldNumber' type BlockMinZoomProps = { value?: number onChange(...args: unknown[]): unknown - error?: unknown[] + error?: {message: string} }; export default class BlockMinZoom extends React.Component { diff --git a/src/components/_FieldSource.tsx b/src/components/_FieldSource.tsx index c8c6c442..0598b989 100644 --- a/src/components/_FieldSource.tsx +++ b/src/components/_FieldSource.tsx @@ -9,7 +9,7 @@ type BlockSourceProps = { wdKey?: string onChange?(...args: unknown[]): unknown sourceIds?: unknown[] - error?: unknown[] + error?: {message: string} }; export default class BlockSource extends React.Component { diff --git a/src/components/_FieldType.tsx b/src/components/_FieldType.tsx index 8dc53009..f23b684d 100644 --- a/src/components/_FieldType.tsx +++ b/src/components/_FieldType.tsx @@ -9,7 +9,7 @@ type BlockTypeProps = { value: string wdKey?: string onChange(...args: unknown[]): unknown - error?: unknown[] + error?: {message: string} disabled?: boolean }; diff --git a/src/components/_SpecProperty.tsx b/src/components/_SpecProperty.tsx index bb7574b3..dc4b877e 100644 --- a/src/components/_SpecProperty.tsx +++ b/src/components/_SpecProperty.tsx @@ -13,7 +13,7 @@ type SpecPropertyProps = SpecFieldProps & { fieldType?: string fieldSpec?: any value?: any - errors?: unknown[] + errors?: {[key: string]: {message: string}} onExpressionClick?(...args: unknown[]): unknown }; diff --git a/src/components/_ZoomProperty.tsx b/src/components/_ZoomProperty.tsx index 54be2ab6..fd3f809e 100644 --- a/src/components/_ZoomProperty.tsx +++ b/src/components/_ZoomProperty.tsx @@ -195,7 +195,7 @@ export default class ZoomProperty extends React.Component this.changeDataType(propVal)} + onChange={(propVal: string) => this.changeDataType(propVal)} title={"Select a type of data scale (default is 'categorical')."} options={this.getDataFunctionTypes(this.props.fieldSpec!)} /> diff --git a/src/libs/layer.ts b/src/libs/layer.ts index b7b0f0c7..38b27d88 100644 --- a/src/libs/layer.ts +++ b/src/libs/layer.ts @@ -27,7 +27,7 @@ export function changeType(layer: LayerSpecification, newType: string) { /** A {@property} in either the paint our layout {@group} has changed * to a {@newValue}. */ -export function changeProperty(layer: LayerSpecification, group: keyof LayerSpecification, property: string, newValue: any) { +export function changeProperty(layer: LayerSpecification, group: keyof LayerSpecification | null, property: string, newValue: any) { // Remove the property if undefined if(newValue === undefined) { if(group) {