@mapbox/mapbox-gl-style-spec 14.11.0 → 14.12.0

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.
Files changed (82) hide show
  1. package/composite.ts +2 -0
  2. package/deref.ts +5 -5
  3. package/diff.ts +65 -31
  4. package/dist/index.cjs +816 -16
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +224 -16
  7. package/dist/index.es.js +816 -16
  8. package/dist/index.es.js.map +1 -1
  9. package/error/validation_error.ts +1 -3
  10. package/expression/compound_expression.ts +1 -1
  11. package/expression/definitions/assertion.ts +2 -1
  12. package/expression/definitions/at.ts +1 -1
  13. package/expression/definitions/at_interpolated.ts +1 -1
  14. package/expression/definitions/case.ts +3 -1
  15. package/expression/definitions/coalesce.ts +3 -2
  16. package/expression/definitions/coercion.ts +3 -1
  17. package/expression/definitions/collator.ts +2 -1
  18. package/expression/definitions/comparison.ts +15 -1
  19. package/expression/definitions/config.ts +4 -1
  20. package/expression/definitions/distance.ts +6 -4
  21. package/expression/definitions/format.ts +1 -1
  22. package/expression/definitions/index.ts +24 -2
  23. package/expression/definitions/index_of.ts +1 -0
  24. package/expression/definitions/interpolate.ts +7 -3
  25. package/expression/definitions/let.ts +1 -0
  26. package/expression/definitions/literal.ts +2 -2
  27. package/expression/definitions/match.ts +4 -2
  28. package/expression/definitions/number_format.ts +3 -4
  29. package/expression/definitions/slice.ts +1 -0
  30. package/expression/definitions/step.ts +2 -1
  31. package/expression/definitions/var.ts +1 -0
  32. package/expression/definitions/within.ts +6 -2
  33. package/expression/evaluation_context.ts +3 -5
  34. package/expression/expression.ts +3 -0
  35. package/expression/index.ts +20 -10
  36. package/expression/parsing_context.ts +1 -1
  37. package/expression/types/image_variant.ts +2 -2
  38. package/expression/types.ts +1 -0
  39. package/expression/values.ts +1 -3
  40. package/feature_filter/convert.ts +13 -6
  41. package/feature_filter/index.ts +17 -1
  42. package/format.ts +1 -0
  43. package/function/convert.ts +5 -1
  44. package/function/index.ts +28 -0
  45. package/group_by_layout.ts +17 -8
  46. package/migrate/expressions.ts +3 -3
  47. package/migrate/v8.ts +10 -1
  48. package/migrate/v9.ts +2 -1
  49. package/migrate.ts +2 -1
  50. package/package.json +1 -1
  51. package/read_style.ts +1 -0
  52. package/reference/latest.ts +1 -0
  53. package/reference/v8.json +425 -8
  54. package/test.js +2 -4
  55. package/types.ts +207 -1
  56. package/union-to-intersection.ts +1 -0
  57. package/util/extend.ts +2 -1
  58. package/util/geometry_util.ts +25 -9
  59. package/util/interpolate.ts +1 -1
  60. package/validate/validate.ts +6 -0
  61. package/validate/validate_array.ts +2 -0
  62. package/validate/validate_enum.ts +1 -0
  63. package/validate/validate_expression.ts +4 -0
  64. package/validate/validate_filter.ts +4 -2
  65. package/validate/validate_fog.ts +4 -1
  66. package/validate/validate_function.ts +7 -2
  67. package/validate/validate_glyphs_url.ts +1 -1
  68. package/validate/validate_iconset.ts +1 -0
  69. package/validate/validate_layer.ts +3 -2
  70. package/validate/validate_light.ts +4 -1
  71. package/validate/validate_lights.ts +7 -1
  72. package/validate/validate_model.ts +4 -0
  73. package/validate/validate_object.ts +2 -2
  74. package/validate/validate_projection.ts +1 -0
  75. package/validate/validate_property.ts +5 -1
  76. package/validate/validate_rain.ts +3 -0
  77. package/validate/validate_snow.ts +3 -0
  78. package/validate/validate_source.ts +9 -9
  79. package/validate/validate_terrain.ts +5 -1
  80. package/validate_mapbox_api_supported.ts +31 -20
  81. package/validate_style.ts +1 -0
  82. package/visit.ts +4 -2
@@ -5,9 +5,7 @@ export default class ValidationError {
5
5
  identifier: string | null | undefined;
6
6
  line: number | null | undefined;
7
7
 
8
- constructor(key: string | null | undefined, value: {
9
- __line__: number;
10
- } | null | undefined, message: string, identifier?: string | null) {
8
+ constructor(key: string | null | undefined, value: (string | number | boolean) & {__line__?: number} | null | undefined, message: string, identifier?: string | null) {
11
9
  this.message = (key ? `${key}: ` : '') + message;
12
10
  if (identifier) this.identifier = identifier;
13
11
 
@@ -73,7 +73,7 @@ class CompoundExpression implements Expression {
73
73
 
74
74
  const overloadParams = [];
75
75
 
76
- let signatureContext: ParsingContext = (null as any);
76
+ let signatureContext: ParsingContext = null;
77
77
 
78
78
  let overloadIndex = -1;
79
79
 
@@ -40,7 +40,7 @@ class Assertion implements Expression {
40
40
  let i = 1;
41
41
  let type;
42
42
 
43
- const name: string = (args[0] as any);
43
+ const name = args[0] as string;
44
44
  if (name === 'array') {
45
45
  let itemType;
46
46
  if (args.length > 2) {
@@ -82,6 +82,7 @@ class Assertion implements Expression {
82
82
  return new Assertion(type, parsed);
83
83
  }
84
84
 
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
86
  evaluate(ctx: EvaluationContext): any {
86
87
  for (let i = 0; i < this.args.length; i++) {
87
88
  const value = this.args[i].evaluate(ctx);
@@ -27,7 +27,7 @@ class At implements Expression {
27
27
 
28
28
  if (!index || !input) return null;
29
29
 
30
- const t: ArrayType = (input.type as any);
30
+ const t = input.type as ArrayType;
31
31
  return new At(t.itemType, index, input);
32
32
  }
33
33
 
@@ -27,7 +27,7 @@ class AtInterpolated implements Expression {
27
27
 
28
28
  if (!index || !input) return null;
29
29
 
30
- const t: ArrayType = (input.type as any);
30
+ const t = input.type as ArrayType;
31
31
  return new AtInterpolated(t.itemType, index, input);
32
32
  }
33
33
 
@@ -50,9 +50,10 @@ class Case implements Expression {
50
50
  if (!otherwise) return null;
51
51
 
52
52
  assert(outputType);
53
- return new Case((outputType as any), branches, otherwise);
53
+ return new Case(outputType, branches, otherwise);
54
54
  }
55
55
 
56
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
57
  evaluate(ctx: EvaluationContext): any {
57
58
  for (const [test, expression] of this.branches) {
58
59
  if (test.evaluate(ctx)) {
@@ -71,6 +72,7 @@ class Case implements Expression {
71
72
  }
72
73
 
73
74
  outputDefined(): boolean {
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
76
  return this.branches.every(([_, out]: [any, any]) => out.outputDefined()) && this.otherwise.outputDefined();
75
77
  }
76
78
 
@@ -21,7 +21,7 @@ class Coalesce implements Expression {
21
21
  // @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Coalesce'.
22
22
  return context.error("Expectected at least one argument.");
23
23
  }
24
- let outputType: Type = (null as any);
24
+ let outputType: Type = null;
25
25
  const expectedType = context.expectedType;
26
26
  if (expectedType && expectedType.kind !== 'value') {
27
27
  outputType = expectedType;
@@ -46,9 +46,10 @@ class Coalesce implements Expression {
46
46
 
47
47
  return needsAnnotation ?
48
48
  new Coalesce(ValueType, parsedArgs) :
49
- new Coalesce((outputType as any), parsedArgs);
49
+ new Coalesce(outputType, parsedArgs);
50
50
  }
51
51
 
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
53
  evaluate(ctx: EvaluationContext): any {
53
54
  let result = null;
54
55
  let argCount = 0;
@@ -40,7 +40,7 @@ class Coercion implements Expression {
40
40
  if (args.length < 2)
41
41
  return context.error(`Expected at least one argument.`);
42
42
 
43
- const name: string = (args[0] as any);
43
+ const name = args[0] as string;
44
44
  const parsed = [];
45
45
  let type: Type | ArrayType = NullType;
46
46
  if (name === 'to-array') {
@@ -93,6 +93,7 @@ class Coercion implements Expression {
93
93
  return new Coercion(type, parsed);
94
94
  }
95
95
 
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
97
  evaluate(ctx: EvaluationContext): any {
97
98
  if (this.type.kind === 'boolean') {
98
99
  return Boolean(this.args[0].evaluate(ctx));
@@ -136,6 +137,7 @@ class Coercion implements Expression {
136
137
  } else if (this.type.kind === 'resolvedImage') {
137
138
  return ResolvedImage.build(valueToString(this.args[0].evaluate(ctx)));
138
139
  } else if (this.type.kind === 'array') {
140
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
139
141
  return this.args.map(arg => { return arg.evaluate(ctx); });
140
142
  } else {
141
143
  return valueToString(this.args[0].evaluate(ctx));
@@ -24,7 +24,7 @@ export default class CollatorExpression implements Expression {
24
24
  // @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
25
25
  return context.error(`Expected one argument.`);
26
26
 
27
- const options = (args[1] as any);
27
+ const options = args[1];
28
28
  if (typeof options !== "object" || Array.isArray(options))
29
29
  // @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
30
30
  return context.error(`Collator options argument must be an object.`);
@@ -69,6 +69,7 @@ export default class CollatorExpression implements Expression {
69
69
  }
70
70
 
71
71
  serialize(): SerializedExpression {
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
73
  const options: Record<string, any> = {};
73
74
  options['case-sensitive'] = this.caseSensitive.serialize();
74
75
  options['diacritic-sensitive'] = this.diacriticSensitive.serialize();
@@ -26,18 +26,30 @@ function isComparableType(op: ComparisonOperator, type: Type) {
26
26
  }
27
27
  }
28
28
 
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
30
  function eq(ctx: EvaluationContext, a: any, b: any): boolean { return a === b; }
31
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
32
  function neq(ctx: EvaluationContext, a: any, b: any): boolean { return a !== b; }
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
34
  function lt(ctx: EvaluationContext, a: any, b: any): boolean { return a < b; }
35
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
36
  function gt(ctx: EvaluationContext, a: any, b: any): boolean { return a > b; }
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
38
  function lteq(ctx: EvaluationContext, a: any, b: any): boolean { return a <= b; }
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
40
  function gteq(ctx: EvaluationContext, a: any, b: any): boolean { return a >= b; }
35
41
 
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
43
  function eqCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean { return c.compare(a, b) === 0; }
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
45
  function neqCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean { return !eqCollate(ctx, a, b, c); }
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
47
  function ltCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean { return c.compare(a, b) < 0; }
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
49
  function gtCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean { return c.compare(a, b) > 0; }
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
51
  function lteqCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean { return c.compare(a, b) <= 0; }
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
53
  function gteqCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean { return c.compare(a, b) >= 0; }
42
54
 
43
55
  /**
@@ -59,7 +71,9 @@ function gteqCollate(ctx: EvaluationContext, a: any, b: any, c: any): boolean {
59
71
  */
60
72
  function makeComparison(
61
73
  op: ComparisonOperator,
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
75
  compareBasic: (arg1: EvaluationContext, arg2?: any, arg3?: any) => boolean,
76
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
77
  compareWithCollator: (arg1: EvaluationContext, arg2?: any, arg3?: any, arg4?: any) => boolean,
64
78
  ): ExpressionRegistration {
65
79
  const isOrderComparison = op !== '==' && op !== '!=';
@@ -83,7 +97,7 @@ function makeComparison(
83
97
  if (args.length !== 3 && args.length !== 4)
84
98
  return context.error(`Expected two or three arguments.`);
85
99
 
86
- const op: ComparisonOperator = (args[0] as any);
100
+ const op = args[0] as ComparisonOperator;
87
101
 
88
102
  let lhs = context.parse(args[1], 1, ValueType);
89
103
  if (!lhs) return null;
@@ -9,6 +9,7 @@ import type {Expression, SerializedExpression} from '../expression';
9
9
  import type ParsingContext from '../parsing_context';
10
10
  import type EvaluationContext from '../evaluation_context';
11
11
 
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
13
  function coerceValue(type: string, value: any): any {
13
14
  switch (type) {
14
15
  case 'string': return valueToString(value);
@@ -74,6 +75,7 @@ class Config implements Expression {
74
75
  return new Config(type, valueToString(configKey.value));
75
76
  }
76
77
 
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
79
  evaluate(ctx: EvaluationContext): any {
78
80
  const FQIDSeparator = '\u001F';
79
81
  const configKey = [this.key, this.scope, ctx.scope].filter(Boolean).join(FQIDSeparator);
@@ -101,7 +103,8 @@ class Config implements Expression {
101
103
  if (typeof result === 'number') {
102
104
  result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
103
105
  } else if (Array.isArray(result)) {
104
- result = result.map((item) => typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
106
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
107
+ result = result.map((item) => (typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item));
105
108
  }
106
109
  }
107
110
 
@@ -147,6 +147,7 @@ function getLngLatPoints(coordinates: Array<Point>, canonical: CanonicalTileID)
147
147
  for (let i = 0; i < coordinates.length; ++i) {
148
148
  coords.push(getLngLatPoint(coordinates[i], canonical));
149
149
  }
150
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
150
151
  return coords;
151
152
  }
152
153
 
@@ -275,6 +276,7 @@ function polygonToPolygonDistance(polygon1: Array<Array<[number, number]>>, poly
275
276
  return dist;
276
277
  }
277
278
 
279
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
278
280
  function updateQueue(distQueue: any, miniDist: number, ruler: CheapRuler, pointSet1: Array<[number, number]>, pointSet2: Array<[number, number]>, r1: IndexRange | null, r2: IndexRange | null) {
279
281
  if (r1 === null || r2 === null) return;
280
282
  const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), ruler);
@@ -527,19 +529,19 @@ class Distance implements Expression {
527
529
  return context.error(`'distance' expression requires either one argument, but found ' ${args.length - 1} instead.`);
528
530
  }
529
531
  if (isValue(args[1])) {
530
- const geojson = (args[1] as any);
532
+ const geojson = args[1] as GeoJSON.GeoJSON;
531
533
  if (geojson.type === 'FeatureCollection') {
532
534
  for (let i = 0; i < geojson.features.length; ++i) {
533
535
  if (isTypeValid(geojson.features[i].geometry.type)) {
534
- return new Distance(geojson, geojson.features[i].geometry);
536
+ return new Distance(geojson, geojson.features[i].geometry as DistanceGeometry);
535
537
  }
536
538
  }
537
539
  } else if (geojson.type === 'Feature') {
538
540
  if (isTypeValid(geojson.geometry.type)) {
539
- return new Distance(geojson, geojson.geometry);
541
+ return new Distance(geojson, geojson.geometry as DistanceGeometry);
540
542
  }
541
543
  } else if (isTypeValid(geojson.type)) {
542
- return new Distance(geojson, geojson);
544
+ return new Distance(geojson, geojson as DistanceGeometry);
543
545
  }
544
546
  }
545
547
  return context.error(
@@ -46,7 +46,7 @@ export default class FormatExpression implements Expression {
46
46
  const sections: Array<FormattedSectionExpression> = [];
47
47
  let nextTokenMayBeObject = false;
48
48
  for (let i = 1; i <= args.length - 1; ++i) {
49
- const arg = (args[i] as any);
49
+ const arg = args[i];
50
50
 
51
51
  if (nextTokenMayBeObject && typeof arg === "object" && !Array.isArray(arg)) {
52
52
  nextTokenMayBeObject = false;
@@ -47,6 +47,7 @@ import Distance from './distance';
47
47
  import {mulberry32} from '../../util/random';
48
48
 
49
49
  import type {Type} from '../types';
50
+ import type {Value} from '../values';
50
51
  import type EvaluationContext from '../evaluation_context';
51
52
  import type {Varargs} from '../compound_expression';
52
53
  import type {Expression, ExpressionRegistry} from '../expression';
@@ -120,6 +121,7 @@ function hsla(ctx: EvaluationContext, [h, s, l, a]: Expression[]) {
120
121
  function has(
121
122
  key: string,
122
123
  obj: {
124
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
125
  [key: string]: any;
124
126
  },
125
127
  ): boolean {
@@ -127,13 +129,17 @@ function has(
127
129
  }
128
130
 
129
131
  function get(key: string, obj: {
132
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
133
  [key: string]: any;
131
134
  }) {
132
135
  const v = obj[key];
136
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
133
137
  return typeof v === 'undefined' ? null : v;
134
138
  }
135
139
 
140
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
141
  function binarySearch(v: any, a: {
142
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
143
  [key: number]: any;
138
144
  }, i: number, j: number) {
139
145
  while (i <= j) {
@@ -180,6 +186,7 @@ CompoundExpression.register(expressions, {
180
186
  array(NumberType, 4),
181
187
  [ColorType],
182
188
  (ctx, [v]) => {
189
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
183
190
  return v.evaluate(ctx).toRenderColor(null).toArray();
184
191
  }
185
192
  ],
@@ -187,6 +194,7 @@ CompoundExpression.register(expressions, {
187
194
  array(NumberType, 4),
188
195
  [ColorType],
189
196
  (ctx, [v]) => {
197
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
190
198
  return v.evaluate(ctx).toRenderColor(null).toHslaArray();
191
199
  }
192
200
  ],
@@ -227,9 +235,11 @@ CompoundExpression.register(expressions, {
227
235
  overloads: [
228
236
  [
229
237
  [StringType],
238
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
230
239
  (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())
231
240
  ], [
232
241
  [StringType, ObjectType],
242
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
233
243
  (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))
234
244
  ]
235
245
  ]
@@ -237,12 +247,13 @@ CompoundExpression.register(expressions, {
237
247
  'feature-state': [
238
248
  ValueType,
239
249
  [StringType],
250
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
240
251
  (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})
241
252
  ],
242
253
  'properties': [
243
254
  ObjectType,
244
255
  [],
245
- (ctx) => ctx.properties()
256
+ (ctx) => ctx.properties() as Value
246
257
  ],
247
258
  'geometry-type': [
248
259
  StringType,
@@ -302,7 +313,7 @@ CompoundExpression.register(expressions, {
302
313
  'accumulated': [
303
314
  ValueType,
304
315
  [],
305
- (ctx) => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated
316
+ (ctx) => (ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated)
306
317
  ],
307
318
  '+': [
308
319
  NumberType,
@@ -421,11 +432,13 @@ CompoundExpression.register(expressions, {
421
432
  'min': [
422
433
  NumberType,
423
434
  varargs(NumberType),
435
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
424
436
  (ctx, args) => Math.min(...args.map(arg => arg.evaluate(ctx)))
425
437
  ],
426
438
  'max': [
427
439
  NumberType,
428
440
  varargs(NumberType),
441
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
429
442
  (ctx, args) => Math.max(...args.map(arg => arg.evaluate(ctx)))
430
443
  ],
431
444
  'abs': [
@@ -578,6 +591,7 @@ CompoundExpression.register(expressions, {
578
591
  overloads: [
579
592
  [
580
593
  [BooleanType, BooleanType],
594
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
581
595
  (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)
582
596
  ],
583
597
  [
@@ -597,6 +611,7 @@ CompoundExpression.register(expressions, {
597
611
  overloads: [
598
612
  [
599
613
  [BooleanType, BooleanType],
614
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
600
615
  (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)
601
616
  ],
602
617
  [
@@ -631,11 +646,13 @@ CompoundExpression.register(expressions, {
631
646
  'upcase': [
632
647
  StringType,
633
648
  [StringType],
649
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
634
650
  (ctx, [s]) => s.evaluate(ctx).toUpperCase()
635
651
  ],
636
652
  'downcase': [
637
653
  StringType,
638
654
  [StringType],
655
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
639
656
  (ctx, [s]) => s.evaluate(ctx).toLowerCase()
640
657
  ],
641
658
  'concat': [
@@ -646,17 +663,21 @@ CompoundExpression.register(expressions, {
646
663
  'resolved-locale': [
647
664
  StringType,
648
665
  [CollatorType],
666
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
649
667
  (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()
650
668
  ],
651
669
  'random': [
652
670
  NumberType,
653
671
  [NumberType, NumberType, ValueType],
654
672
  (ctx, args) => {
673
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
655
674
  const [min, max, seed] = args.map(arg => arg.evaluate(ctx));
656
675
  if (min > max) {
676
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
657
677
  return min;
658
678
  }
659
679
  if (min === max) {
680
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
660
681
  return min;
661
682
  }
662
683
  let seedVal;
@@ -668,6 +689,7 @@ CompoundExpression.register(expressions, {
668
689
  throw new RuntimeError(`Invalid seed input: ${seed}`);
669
690
  }
670
691
  const random = mulberry32(seedVal)();
692
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
671
693
  return min + random * (max - min);
672
694
  }
673
695
  ],
@@ -54,6 +54,7 @@ class IndexOf implements Expression {
54
54
  }
55
55
  }
56
56
 
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
58
  evaluate(ctx: EvaluationContext): any {
58
59
  const needle = (this.needle.evaluate(ctx));
59
60
  const haystack = (this.haystack.evaluate(ctx));
@@ -91,7 +91,7 @@ class Interpolate implements Expression {
91
91
 
92
92
  interpolation = {
93
93
  name: 'cubic-bezier',
94
- controlPoints: (controlPoints as any)
94
+ controlPoints
95
95
  };
96
96
  } else {
97
97
  return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);
@@ -110,7 +110,7 @@ class Interpolate implements Expression {
110
110
 
111
111
  const stops: Stops = [];
112
112
 
113
- let outputType: Type = (null as any);
113
+ let outputType: Type = null;
114
114
  if (operator === 'interpolate-hcl' || operator === 'interpolate-lab') {
115
115
  outputType = ColorType;
116
116
  } else if (context.expectedType && context.expectedType.kind !== 'value') {
@@ -157,16 +157,19 @@ class Interpolate implements Expression {
157
157
  const outputs = this.outputs;
158
158
 
159
159
  if (labels.length === 1) {
160
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
160
161
  return outputs[0].evaluate(ctx);
161
162
  }
162
163
 
163
164
  const value = (this.input.evaluate(ctx) as number);
164
165
  if (value <= labels[0]) {
166
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
165
167
  return outputs[0].evaluate(ctx);
166
168
  }
167
169
 
168
170
  const stopCount = labels.length;
169
171
  if (value >= labels[stopCount - 1]) {
172
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
170
173
  return outputs[stopCount - 1].evaluate(ctx);
171
174
  }
172
175
 
@@ -179,7 +182,8 @@ class Interpolate implements Expression {
179
182
  const outputUpper = outputs[index + 1].evaluate(ctx);
180
183
 
181
184
  if (this.operator === 'interpolate') {
182
- return (interpolate[this.type.kind.toLowerCase()] as any)(outputLower, outputUpper, t);
185
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
186
+ return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
183
187
  } else if (this.operator === 'interpolate-hcl') {
184
188
  return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
185
189
  } else {
@@ -14,6 +14,7 @@ class Let implements Expression {
14
14
  this.result = result;
15
15
  }
16
16
 
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
18
  evaluate(ctx: EvaluationContext): any {
18
19
  return this.result.evaluate(ctx);
19
20
  }
@@ -23,7 +23,7 @@ class Literal implements Expression {
23
23
  if (!isValue(args[1]))
24
24
  return context.error(`invalid value`);
25
25
 
26
- const value = (args[1] as any);
26
+ const value = args[1] as Value;
27
27
  let type = typeOf(value);
28
28
 
29
29
  // special case: infer the item type if possible for zero-length arrays
@@ -67,7 +67,7 @@ class Literal implements Expression {
67
67
  typeof this.value === 'string' ||
68
68
  typeof this.value === 'number' ||
69
69
  typeof this.value === 'boolean');
70
- return this.value as any;
70
+ return this.value as SerializedExpression;
71
71
  }
72
72
  }
73
73
  }
@@ -39,6 +39,7 @@ class Match implements Expression {
39
39
  if (context.expectedType && context.expectedType.kind !== 'value') {
40
40
  outputType = context.expectedType;
41
41
  }
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
43
  const cases: Record<string, any> = {};
43
44
  const outputs = [];
44
45
  for (let i = 2; i < args.length - 1; i += 2) {
@@ -94,9 +95,10 @@ class Match implements Expression {
94
95
  return null;
95
96
  }
96
97
 
97
- return new Match((inputType), (outputType as any), input, cases, outputs, otherwise);
98
+ return new Match(inputType, outputType, input, cases, outputs, otherwise);
98
99
  }
99
100
 
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
102
  evaluate(ctx: EvaluationContext): any {
101
103
  const input = (this.input.evaluate(ctx));
102
104
  const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;
@@ -138,7 +140,7 @@ class Match implements Expression {
138
140
  }
139
141
  }
140
142
 
141
- const coerceLabel = (label: number | string) => this.inputType.kind === 'number' ? Number(label) : label;
143
+ const coerceLabel = (label: number | string) => (this.inputType.kind === 'number' ? Number(label) : label);
142
144
 
143
145
  for (const [outputIndex, labels] of groupedByOutput) {
144
146
  if (labels.length === 1) {
@@ -29,17 +29,15 @@ export default class NumberFormat implements Expression {
29
29
  this.maxFractionDigits = maxFractionDigits;
30
30
  }
31
31
 
32
- static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | null | undefined {
32
+ static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Expression | void {
33
33
  if (args.length !== 3)
34
- // @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
35
34
  return context.error(`Expected two arguments.`);
36
35
 
37
36
  const number = context.parse(args[1], 1, NumberType);
38
37
  if (!number) return null;
39
38
 
40
- const options = (args[2] as any);
39
+ const options = args[2];
41
40
  if (typeof options !== "object" || Array.isArray(options))
42
- // @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
43
41
  return context.error(`NumberFormat options argument must be an object.`);
44
42
 
45
43
  let locale = null;
@@ -113,6 +111,7 @@ export default class NumberFormat implements Expression {
113
111
  }
114
112
 
115
113
  serialize(): SerializedExpression {
114
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
115
  const options: Record<string, any> = {};
117
116
  if (this.locale) {
118
117
  options['locale'] = this.locale.serialize();
@@ -54,6 +54,7 @@ class Slice implements Expression {
54
54
  }
55
55
  }
56
56
 
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
58
  evaluate(ctx: EvaluationContext): any {
58
59
  const input = (this.input.evaluate(ctx));
59
60
  const beginIndex = (this.beginIndex.evaluate(ctx) as number);
@@ -40,7 +40,7 @@ class Step implements Expression {
40
40
 
41
41
  const stops: Stops = [];
42
42
 
43
- let outputType: Type = (null as any);
43
+ let outputType: Type = null;
44
44
  if (context.expectedType && context.expectedType.kind !== 'value') {
45
45
  outputType = context.expectedType;
46
46
  }
@@ -69,6 +69,7 @@ class Step implements Expression {
69
69
  return new Step(outputType, input, stops);
70
70
  }
71
71
 
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
73
  evaluate(ctx: EvaluationContext): any {
73
74
  const labels = this.labels;
74
75
  const outputs = this.outputs;
@@ -26,6 +26,7 @@ class Var implements Expression {
26
26
  return new Var(name, context.scope.get(name));
27
27
  }
28
28
 
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
30
  evaluate(ctx: EvaluationContext): any {
30
31
  return this.boundExpression.evaluate(ctx);
31
32
  }
@@ -85,6 +85,7 @@ function getTilePolygon(coordinates: Array<Array<GeoJSON.Position>>, bbox: BBox,
85
85
  }
86
86
  polygon.push(ring);
87
87
  }
88
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
88
89
  return polygon;
89
90
  }
90
91
 
@@ -94,6 +95,7 @@ function getTilePolygons(coordinates: Array<Array<Array<GeoJSON.Position>>>, bbo
94
95
  const polygon = getTilePolygon(coordinates[i], bbox, canonical);
95
96
  polygons.push(polygon);
96
97
  }
98
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
97
99
  return polygons;
98
100
  }
99
101
 
@@ -118,6 +120,7 @@ function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBB
118
120
  const worldSize = Math.pow(2, canonical.z) * EXTENT;
119
121
  const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];
120
122
  const tilePoints = [];
123
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
121
124
  if (!geometry) return tilePoints;
122
125
  for (const points of geometry) {
123
126
  for (const point of points) {
@@ -126,6 +129,7 @@ function getTilePoints(geometry: Array<Array<Point>> | null | undefined, pointBB
126
129
  tilePoints.push(p);
127
130
  }
128
131
  }
132
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
129
133
  return tilePoints;
130
134
  }
131
135
 
@@ -230,12 +234,12 @@ class Within implements Expression {
230
234
  if (args.length !== 2)
231
235
  return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);
232
236
  if (isValue(args[1])) {
233
- const geojson = (args[1] as any);
237
+ const geojson = args[1] as GeoJSON.GeoJSON;
234
238
  if (geojson.type === 'FeatureCollection') {
235
239
  for (let i = 0; i < geojson.features.length; ++i) {
236
240
  const type = geojson.features[i].geometry.type;
237
241
  if (type === 'Polygon' || type === 'MultiPolygon') {
238
- return new Within(geojson, geojson.features[i].geometry);
242
+ return new Within(geojson, geojson.features[i].geometry as GeoJSONPolygons);
239
243
  }
240
244
  }
241
245
  } else if (geojson.type === 'Feature') {