@mapbox/mapbox-gl-style-spec 14.31.0 → 14.32.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/function/index.ts CHANGED
@@ -1,6 +1,3 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
- // @ts-nocheck
3
-
4
1
  import * as colorSpaces from '../util/color_spaces';
5
2
  import Color from '../util/color';
6
3
  import {getType, isNumber} from '../util/get_type';
@@ -11,60 +8,76 @@ import ResolvedImage from '../expression/types/resolved_image';
11
8
  import {supportsInterpolation} from '../util/properties';
12
9
  import {findStopLessThanOrEqualTo} from '../expression/stops';
13
10
 
14
- import type {FunctionSpecification} from '../types';
15
-
16
- export function isFunction(value) {
11
+ import type {InterpolationType} from '../expression/definitions/interpolate';
12
+ import type {StylePropertySpecification} from '../style-spec';
13
+ import type {
14
+ FunctionSpecification,
15
+ PropertyFunctionStop,
16
+ SourceFunctionSpecification,
17
+ ZoomAndPropertyFunctionStop
18
+ } from '../types';
19
+
20
+ type StopKey = ZoomAndPropertyFunctionStop<unknown>[0]['value'];
21
+ type CompositeStopInput = ZoomAndPropertyFunctionStop<unknown>[0];
22
+ type Stop = [StopKey | CompositeStopInput, unknown];
23
+ type CategoricalStop = Extract<SourceFunctionSpecification<unknown>, {type: 'categorical'}>['stops'][number];
24
+ type NumericStop = PropertyFunctionStop<unknown>;
25
+ type FunctionParameters = Pick<FunctionSpecification<unknown>, 'base' | 'property' | 'type' | 'default'> & {
26
+ stops?: Stop[];
27
+ colorSpace?: string;
28
+ };
29
+ type FeatureLike = {properties?: Record<string, unknown>};
30
+ type HashedStops = Record<string, unknown>;
31
+ type EvaluationArguments = [globals: {zoom: number} | number, feature?: FeatureLike | null];
32
+ type Evaluator = {evaluate: (...args: EvaluationArguments) => unknown};
33
+ type EvaluationFunction = (
34
+ parameters: FunctionParameters,
35
+ propertySpec: StylePropertySpecification,
36
+ input: unknown,
37
+ hashedStops?: HashedStops,
38
+ categoricalKeyType?: string,
39
+ ) => unknown;
40
+ type InterpolationFunction = (from: unknown, to: unknown, t: number) => unknown;
41
+ type ColorSpace = Record<'forward' | 'reverse', typeof identityFunction> & {interpolate: InterpolationFunction};
42
+
43
+ export function isFunction(value: unknown): boolean {
17
44
  return typeof value === 'object' && value !== null && !Array.isArray(value);
18
45
  }
19
46
 
20
- function identityFunction(x) {
21
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
47
+ function identityFunction(x: unknown): unknown {
22
48
  return x;
23
49
  }
24
50
 
25
- export function createFunction(parameters, propertySpec) {
26
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
51
+ export function createFunction(input: unknown, propertySpec: StylePropertySpecification) {
52
+ let parameters = input as FunctionParameters;
27
53
  const isColor = propertySpec.type === 'color';
28
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
29
- const zoomAndFeatureDependent = (parameters.stops as FunctionSpecification<unknown>['stops'] | undefined) && typeof parameters.stops[0][0] === 'object';
30
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
54
+ const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0]![0] === 'object';
31
55
  const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
32
56
  const zoomDependent = zoomAndFeatureDependent || !featureDependent;
33
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
34
57
  const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');
35
58
 
36
59
  if (isColor) {
37
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
38
60
  parameters = {...parameters};
39
61
 
40
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
41
62
  if (parameters.stops) {
42
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
43
63
  parameters.stops = parameters.stops.map((stop) => {
44
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
45
- return [stop[0], Color.parse(stop[1])];
64
+ return [stop[0], Color.parse(stop[1] as string | Color | null)];
46
65
  });
47
66
  }
48
67
 
49
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
50
68
  if (parameters.default) {
51
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
52
- parameters.default = Color.parse(parameters.default);
69
+ parameters.default = Color.parse(parameters.default as string | Color);
53
70
  } else {
54
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
55
71
  parameters.default = Color.parse(propertySpec.default);
56
72
  }
57
73
  }
58
74
 
59
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
60
- if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace]) {
61
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
75
+ if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace as keyof typeof colorSpaces]) {
62
76
  throw new Error(`Unknown color space: ${parameters.colorSpace}`);
63
77
  }
64
78
 
65
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
- let innerFun: ((parameters: any, propertySpec: any, input: any, hashedStops?: any, categoricalKeyType?: any) => any) | undefined;
67
- let hashedStops: Record<string | number, unknown> | undefined;
79
+ let innerFun: EvaluationFunction;
80
+ let hashedStops: HashedStops | undefined;
68
81
  let categoricalKeyType: string | undefined;
69
82
  if (type === 'exponential') {
70
83
  innerFun = evaluateExponentialFunction;
@@ -74,17 +87,13 @@ export function createFunction(parameters, propertySpec) {
74
87
  innerFun = evaluateCategoricalFunction;
75
88
 
76
89
  // For categorical functions, generate an Object as a hashmap of the stops for fast searching
77
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
78
- hashedStops = Object.create(null);
79
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
80
- for (const stop of parameters.stops) {
81
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
82
- hashedStops[stop[0]] = stop[1];
90
+ hashedStops = Object.create(null) as HashedStops;
91
+ for (const stop of parameters.stops as CategoricalStop[]) {
92
+ hashedStops[stop[0] as string | number] = stop[1];
83
93
  }
84
94
 
85
95
  // Infer key type based on first stop key-- used to encforce strict type checking later
86
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
87
- categoricalKeyType = typeof parameters.stops[0][0];
96
+ categoricalKeyType = typeof (parameters.stops as CategoricalStop[])[0]![0];
88
97
 
89
98
  } else if (type === 'identity') {
90
99
  innerFun = evaluateIdentityFunction;
@@ -93,206 +102,149 @@ export function createFunction(parameters, propertySpec) {
93
102
  }
94
103
 
95
104
  if (zoomAndFeatureDependent) {
96
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
- const featureFunctions: Record<string, any> = {};
98
- const zoomStops = [];
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
100
- for (let s = 0; s < parameters.stops.length; s++) {
101
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
102
- const stop = parameters.stops[s];
103
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
105
+ const featureFunctions: Record<string, FunctionParameters & {zoom: number; stops: Stop[]}> = {};
106
+ const zoomStops: number[] = [];
107
+ for (let s = 0; s < parameters.stops!.length; s++) {
108
+ const stop = parameters.stops![s] as [CompositeStopInput, unknown];
104
109
  const zoom = stop[0].zoom;
105
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
106
110
  if (featureFunctions[zoom] === undefined) {
107
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
108
111
  featureFunctions[zoom] = {
109
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
110
112
  zoom,
111
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
112
113
  type: parameters.type,
113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
114
114
  property: parameters.property,
115
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
116
115
  default: parameters.default,
117
116
  stops: []
118
117
  };
119
118
  zoomStops.push(zoom);
120
119
  }
121
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
122
120
  featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);
123
121
  }
124
122
 
125
- const featureFunctionStops = [];
123
+ const featureFunctionStops: Array<[number, Evaluator]> = [];
126
124
  for (const z of zoomStops) {
127
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
128
- featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z], propertySpec)]);
125
+ featureFunctionStops.push([featureFunctions[z]!.zoom, createFunction(featureFunctions[z]!, propertySpec) as Evaluator]);
129
126
  }
130
127
 
131
- const interpolationType = {name: 'linear'};
128
+ const interpolationType: InterpolationType = {name: 'linear'};
132
129
  return {
133
130
  kind: 'composite',
134
131
  interpolationType,
135
132
 
136
133
  interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),
137
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
138
134
  zoomStops: featureFunctionStops.map(s => s[0]),
139
- evaluate({zoom}, properties) {
140
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
141
- return evaluateExponentialFunction({
135
+ evaluate({zoom}: {zoom: number}, properties: FeatureLike | null | undefined) {
136
+ return (evaluateExponentialFunction({
142
137
  stops: featureFunctionStops,
143
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
144
138
  base: parameters.base
145
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
146
- }, propertySpec, zoom).evaluate(zoom, properties);
139
+ }, propertySpec, zoom) as Evaluator).evaluate(zoom, properties);
147
140
  }
148
141
  };
149
142
  } else if (zoomDependent) {
150
- const interpolationType = type === 'exponential' ?
151
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
143
+ const interpolationType: InterpolationType | null = type === 'exponential' ?
152
144
  {name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1} : null;
153
145
  return {
154
146
  kind: 'camera',
155
147
  interpolationType,
156
148
 
157
- interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),
158
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
159
- zoomStops: parameters.stops.map(s => s[0]),
160
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
161
- evaluate: ({zoom}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
149
+ interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType as InterpolationType),
150
+ zoomStops: parameters.stops!.map(s => s[0]),
151
+ evaluate: ({zoom}: {zoom: number}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
162
152
  };
163
153
  } else {
164
154
  return {
165
155
  kind: 'source',
166
- evaluate(_, feature) {
167
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
168
- const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;
156
+ evaluate(_: unknown, feature: FeatureLike | null | undefined) {
157
+ const value = feature && feature.properties ? feature.properties[parameters.property!] : undefined;
169
158
  if (value === undefined) {
170
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
171
159
  return coalesce(parameters.default, propertySpec.default);
172
160
  }
173
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
174
161
  return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);
175
162
  }
176
163
  };
177
164
  }
178
165
  }
179
166
 
180
- function coalesce(a, b, c) {
181
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
167
+ function coalesce(a: unknown, b: unknown, c?: unknown): unknown {
182
168
  if (a !== undefined) return a;
183
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
184
169
  if (b !== undefined) return b;
185
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
186
170
  if (c !== undefined) return c;
187
171
  }
188
172
 
189
- function evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {
190
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
191
- const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input
192
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
173
+ function evaluateCategoricalFunction(
174
+ parameters: FunctionParameters,
175
+ propertySpec: StylePropertySpecification,
176
+ input: unknown,
177
+ hashedStops?: HashedStops,
178
+ keyType?: string,
179
+ ): unknown {
180
+ const evaluated = typeof input === keyType ? hashedStops![input as string | number] : undefined; // Enforce strict typing on input
193
181
  return coalesce(evaluated, parameters.default, propertySpec.default);
194
182
  }
195
183
 
196
- function evaluateIntervalFunction(parameters, propertySpec, input) {
184
+ function evaluateIntervalFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, input: unknown): unknown {
197
185
  // Edge cases
198
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
199
186
  if (!isNumber(input)) return coalesce(parameters.default, propertySpec.default);
200
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
201
- const n = parameters.stops.length;
202
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
203
- if (n === 1) return parameters.stops[0][1];
204
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
205
- if (input <= parameters.stops[0][0]) return parameters.stops[0][1];
206
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
207
- if (input >= parameters.stops[n - 1][0]) return parameters.stops[n - 1][1];
208
-
209
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
210
- const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);
211
-
212
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
213
- return parameters.stops[index][1];
187
+ const stops = parameters.stops as NumericStop[];
188
+ const n = stops.length;
189
+ if (n === 1) return stops[0]![1];
190
+ if (input <= stops[0]![0]) return stops[0]![1];
191
+ if (input >= stops[n - 1]![0]) return stops[n - 1]![1];
192
+
193
+ const index = findStopLessThanOrEqualTo(stops.map((stop) => stop[0]), input);
194
+
195
+ return stops[index]![1];
214
196
  }
215
197
 
216
- function evaluateExponentialFunction(parameters, propertySpec, input) {
217
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
198
+ function evaluateExponentialFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, input: unknown): unknown {
218
199
  const base = parameters.base !== undefined ? parameters.base : 1;
219
200
 
220
201
  // Edge cases
221
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
222
202
  if (!isNumber(input)) return coalesce(parameters.default, propertySpec.default);
223
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
224
- const n = parameters.stops.length;
225
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
226
- if (n === 1) return parameters.stops[0][1];
227
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
228
- if (input <= parameters.stops[0][0]) return parameters.stops[0][1];
229
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
230
- if (input >= parameters.stops[n - 1][0]) return parameters.stops[n - 1][1];
231
-
232
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
233
- const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);
234
- const t = interpolationFactor(
235
- input, base,
236
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
237
- parameters.stops[index][0],
238
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
239
- parameters.stops[index + 1][0]);
240
-
241
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
242
- const outputLower = parameters.stops[index][1];
243
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
244
- const outputUpper = parameters.stops[index + 1][1];
245
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
246
- let interp = interpolate[propertySpec.type] || identityFunction;
247
-
248
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
203
+ const stops = parameters.stops as NumericStop[];
204
+ const n = stops.length;
205
+ if (n === 1) return stops[0]![1];
206
+ if (input <= stops[0]![0]) return stops[0]![1];
207
+ if (input >= stops[n - 1]![0]) return stops[n - 1]![1];
208
+
209
+ const index = findStopLessThanOrEqualTo(stops.map((stop) => stop[0]), input);
210
+ const t = interpolationFactor(input, base, stops[index]![0], stops[index + 1]![0]);
211
+
212
+ const outputLower = stops[index]![1];
213
+ const outputUpper = stops[index + 1]![1];
214
+ let interp = (interpolate[propertySpec.type as keyof typeof interpolate] as InterpolationFunction | undefined) || identityFunction;
215
+
249
216
  if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
250
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
251
- const colorspace = colorSpaces[parameters.colorSpace];
252
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
217
+ const colorspace = colorSpaces[parameters.colorSpace as keyof typeof colorSpaces] as ColorSpace;
253
218
  interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
254
219
  }
255
220
 
256
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
257
- if (typeof outputLower.evaluate === 'function') {
221
+ if (typeof (outputLower as Partial<Evaluator>).evaluate === 'function') {
258
222
  return {
259
- evaluate(...args) {
260
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
261
- const evaluatedLower = outputLower.evaluate.apply(undefined, args);
262
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
263
- const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);
223
+ evaluate(...args: EvaluationArguments) {
224
+ const evaluatedLower = (outputLower as Evaluator).evaluate.apply(undefined, args);
225
+ const evaluatedUpper = (outputUpper as Evaluator).evaluate.apply(undefined, args);
264
226
  // Special case for fill-outline-color, which has no spec default.
265
227
  if (evaluatedLower === undefined || evaluatedUpper === undefined) {
266
228
  return undefined;
267
229
  }
268
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
269
230
  return interp(evaluatedLower, evaluatedUpper, t);
270
231
  }
271
232
  };
272
233
  }
273
234
 
274
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
275
235
  return interp(outputLower, outputUpper, t);
276
236
  }
277
237
 
278
- function evaluateIdentityFunction(parameters, propertySpec, input) {
279
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
238
+ function evaluateIdentityFunction(parameters: FunctionParameters, propertySpec: StylePropertySpecification, input: unknown): unknown {
280
239
  if (propertySpec.type === 'color') {
281
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
282
- input = Color.parse(input);
283
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
240
+ input = Color.parse(input as string | Color | null);
284
241
  } else if (propertySpec.type === 'formatted') {
285
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
286
- input = Formatted.fromString(input.toString());
287
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
242
+ input = Formatted.fromString((input as {toString: () => string}).toString());
288
243
  } else if (propertySpec.type === 'resolvedImage') {
289
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
290
- input = ResolvedImage.build(input.toString());
291
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
292
- } else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {
244
+ input = ResolvedImage.build((input as {toString: () => string}).toString());
245
+ } else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values![input as keyof typeof propertySpec.values])) {
293
246
  input = undefined;
294
247
  }
295
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
296
248
  return coalesce(input, parameters.default, propertySpec.default);
297
249
  }
298
250
 
@@ -334,7 +286,7 @@ function evaluateIdentityFunction(parameters, propertySpec, input) {
334
286
  *
335
287
  * @private
336
288
  */
337
- function interpolationFactor(input, base, lowerValue, upperValue) {
289
+ function interpolationFactor(input: number, base: number, lowerValue: number, upperValue: number): number {
338
290
  const difference = upperValue - lowerValue;
339
291
  const progress = input - lowerValue;
340
292
 
@@ -343,7 +295,6 @@ function interpolationFactor(input, base, lowerValue, upperValue) {
343
295
  } else if (base === 1) {
344
296
  return progress / difference;
345
297
  } else {
346
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
347
298
  return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
348
299
  }
349
300
  }