@mapbox/mapbox-gl-style-spec 14.10.0 → 14.11.0-beta.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/composite.ts +1 -0
- package/dist/index.cjs +252 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +27 -3
- package/dist/index.es.js +252 -67
- package/dist/index.es.js.map +1 -1
- package/expression/compound_expression.ts +5 -7
- package/expression/definitions/at.ts +5 -19
- package/expression/definitions/at_interpolated.ts +80 -0
- package/expression/definitions/coercion.ts +1 -5
- package/expression/definitions/comparison.ts +2 -8
- package/expression/definitions/config.ts +1 -4
- package/expression/definitions/distance.ts +28 -43
- package/expression/definitions/format.ts +4 -9
- package/expression/definitions/image.ts +1 -2
- package/expression/definitions/index.ts +3 -2
- package/expression/definitions/interpolate.ts +28 -80
- package/expression/definitions/let.ts +2 -7
- package/expression/definitions/literal.ts +1 -2
- package/expression/definitions/match.ts +3 -12
- package/expression/definitions/step.ts +1 -5
- package/expression/evaluation_context.ts +1 -2
- package/expression/index.ts +1 -8
- package/expression/parsing_context.ts +3 -7
- package/format.ts +1 -0
- package/function/index.ts +1 -0
- package/migrate/v8.ts +1 -0
- package/migrate/v9.ts +1 -0
- package/migrate.ts +1 -0
- package/package.json +1 -1
- package/read_style.ts +1 -0
- package/reference/v8.json +153 -6
- package/types.ts +30 -2
- package/util/color.ts +1 -1
- package/validate/validate.ts +6 -1
- package/validate/validate_iconset.ts +40 -0
- package/validate/validate_layer.ts +1 -5
- package/validate/validate_lights.ts +3 -2
- package/validate/validate_object.ts +2 -0
- package/validate/validate_style.ts +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import UnitBezier from '@mapbox/unitbezier';
|
|
2
2
|
import * as interpolate from '../../util/interpolate';
|
|
3
|
-
import {toString, NumberType, ColorType
|
|
3
|
+
import {toString, NumberType, ColorType} from '../types';
|
|
4
4
|
import {findStopLessThanOrEqualTo} from '../stops';
|
|
5
5
|
import {hcl, lab} from '../../util/color_spaces';
|
|
6
|
-
import Literal from './literal';
|
|
7
|
-
import RuntimeError from '../runtime_error';
|
|
8
6
|
|
|
9
7
|
import type Color from '../../util/color';
|
|
10
8
|
import type {Stops} from '../stops';
|
|
@@ -13,32 +11,30 @@ import type ParsingContext from '../parsing_context';
|
|
|
13
11
|
import type EvaluationContext from '../evaluation_context';
|
|
14
12
|
import type {Type} from '../types';
|
|
15
13
|
|
|
16
|
-
export type InterpolationType =
|
|
17
|
-
name: 'linear'
|
|
18
|
-
|
|
19
|
-
name: '
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
export type InterpolationType =
|
|
15
|
+
| {name: 'linear'}
|
|
16
|
+
| {name: 'exponential'; base: number}
|
|
17
|
+
| {name: 'cubic-bezier'; controlPoints: [number, number, number, number]};
|
|
18
|
+
|
|
19
|
+
export type InterpolationOperator =
|
|
20
|
+
| 'interpolate'
|
|
21
|
+
| 'interpolate-hcl'
|
|
22
|
+
| 'interpolate-lab';
|
|
25
23
|
|
|
26
24
|
class Interpolate implements Expression {
|
|
27
25
|
type: Type;
|
|
28
26
|
|
|
29
|
-
operator:
|
|
27
|
+
operator: InterpolationOperator;
|
|
30
28
|
interpolation: InterpolationType;
|
|
31
29
|
input: Expression;
|
|
32
|
-
dynamicStops: Expression | null;
|
|
33
30
|
labels: Array<number>;
|
|
34
31
|
outputs: Array<Expression>;
|
|
35
32
|
|
|
36
|
-
constructor(type: Type, operator:
|
|
33
|
+
constructor(type: Type, operator: InterpolationOperator, interpolation: InterpolationType, input: Expression, stops: Stops) {
|
|
37
34
|
this.type = type;
|
|
38
35
|
this.operator = operator;
|
|
39
36
|
this.interpolation = interpolation;
|
|
40
37
|
this.input = input;
|
|
41
|
-
this.dynamicStops = dynamicStops;
|
|
42
38
|
|
|
43
39
|
this.labels = [];
|
|
44
40
|
this.outputs = [];
|
|
@@ -67,11 +63,10 @@ class Interpolate implements Expression {
|
|
|
67
63
|
return t;
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Interpolate | null |
|
|
66
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Interpolate | null | void {
|
|
71
67
|
let [operator, interpolation, input, ...rest] = args;
|
|
72
68
|
|
|
73
69
|
if (!Array.isArray(interpolation) || interpolation.length === 0) {
|
|
74
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
75
70
|
return context.error(`Expected an interpolation type expression.`, 1);
|
|
76
71
|
}
|
|
77
72
|
|
|
@@ -80,7 +75,6 @@ class Interpolate implements Expression {
|
|
|
80
75
|
} else if (interpolation[0] === 'exponential') {
|
|
81
76
|
const base = interpolation[1];
|
|
82
77
|
if (typeof base !== 'number')
|
|
83
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
84
78
|
return context.error(`Exponential interpolation requires a numeric base.`, 1, 1);
|
|
85
79
|
interpolation = {
|
|
86
80
|
name: 'exponential',
|
|
@@ -92,7 +86,6 @@ class Interpolate implements Expression {
|
|
|
92
86
|
controlPoints.length !== 4 ||
|
|
93
87
|
controlPoints.some(t => typeof t !== 'number' || t < 0 || t > 1)
|
|
94
88
|
) {
|
|
95
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
96
89
|
return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);
|
|
97
90
|
}
|
|
98
91
|
|
|
@@ -101,17 +94,14 @@ class Interpolate implements Expression {
|
|
|
101
94
|
controlPoints: (controlPoints as any)
|
|
102
95
|
};
|
|
103
96
|
} else {
|
|
104
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
105
97
|
return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);
|
|
106
98
|
}
|
|
107
99
|
|
|
108
|
-
if (args.length - 1 <
|
|
109
|
-
|
|
110
|
-
return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);
|
|
100
|
+
if (args.length - 1 < 4) {
|
|
101
|
+
return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);
|
|
111
102
|
}
|
|
112
103
|
|
|
113
104
|
if (args.length - 1 > 3 && (args.length - 1) % 2 !== 0) {
|
|
114
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
115
105
|
return context.error(`Expected an even number of arguments.`);
|
|
116
106
|
}
|
|
117
107
|
|
|
@@ -127,15 +117,6 @@ class Interpolate implements Expression {
|
|
|
127
117
|
outputType = context.expectedType;
|
|
128
118
|
}
|
|
129
119
|
|
|
130
|
-
// Exactly 3 arguments means that the steps are created by an expression
|
|
131
|
-
if (args.length - 1 === 3) {
|
|
132
|
-
const dynamicStops = context.parse(rest[0], 3, ValueType);
|
|
133
|
-
if (!dynamicStops) return null;
|
|
134
|
-
|
|
135
|
-
// @ts-expect-error - TS2345 - Argument of type 'unknown' is not assignable to parameter of type 'InterpolationType'.
|
|
136
|
-
return new Interpolate(outputType, (operator as any), interpolation, input, dynamicStops, stops);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
120
|
for (let i = 0; i < rest.length; i += 2) {
|
|
140
121
|
const label = rest[i];
|
|
141
122
|
const value = rest[i + 1];
|
|
@@ -144,12 +125,10 @@ class Interpolate implements Expression {
|
|
|
144
125
|
const valueKey = i + 4;
|
|
145
126
|
|
|
146
127
|
if (typeof label !== 'number') {
|
|
147
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
148
128
|
return context.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
|
|
149
129
|
}
|
|
150
130
|
|
|
151
131
|
if (stops.length && stops[stops.length - 1][0] >= label) {
|
|
152
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
153
132
|
return context.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.', labelKey);
|
|
154
133
|
}
|
|
155
134
|
|
|
@@ -167,41 +146,15 @@ class Interpolate implements Expression {
|
|
|
167
146
|
typeof outputType.N === 'number'
|
|
168
147
|
)
|
|
169
148
|
) {
|
|
170
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Interpolate'.
|
|
171
149
|
return context.error(`Type ${toString(outputType)} is not interpolatable.`);
|
|
172
150
|
}
|
|
173
151
|
|
|
174
|
-
|
|
175
|
-
return new Interpolate(outputType, (operator as any), interpolation, input, null, stops);
|
|
152
|
+
return new Interpolate(outputType, operator as InterpolationOperator, interpolation as InterpolationType, input as Expression, stops);
|
|
176
153
|
}
|
|
177
154
|
|
|
178
155
|
evaluate(ctx: EvaluationContext): Color {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (this.dynamicStops) {
|
|
183
|
-
const dynamicStopsValue = (this.dynamicStops.evaluate(ctx) as [number]);
|
|
184
|
-
if (dynamicStopsValue.length % 2 !== 0) {
|
|
185
|
-
throw new RuntimeError('Expected an even number of arguments.');
|
|
186
|
-
}
|
|
187
|
-
labels = [];
|
|
188
|
-
outputs = [];
|
|
189
|
-
for (let i = 0; i < dynamicStopsValue.length; i += 2) {
|
|
190
|
-
const label = dynamicStopsValue[i];
|
|
191
|
-
const output = new Literal(NumberType, dynamicStopsValue[i + 1]);
|
|
192
|
-
if (typeof label !== 'number') {
|
|
193
|
-
throw new RuntimeError('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.');
|
|
194
|
-
}
|
|
195
|
-
if (labels.length && labels[labels.length - 1] >= label) {
|
|
196
|
-
throw new RuntimeError('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.');
|
|
197
|
-
}
|
|
198
|
-
labels.push(label);
|
|
199
|
-
outputs.push(output);
|
|
200
|
-
}
|
|
201
|
-
if (labels.length === 0) {
|
|
202
|
-
throw new RuntimeError('Expected at least one input/output pair.');
|
|
203
|
-
}
|
|
204
|
-
}
|
|
156
|
+
const labels = this.labels;
|
|
157
|
+
const outputs = this.outputs;
|
|
205
158
|
|
|
206
159
|
if (labels.length === 1) {
|
|
207
160
|
return outputs[0].evaluate(ctx);
|
|
@@ -246,31 +199,26 @@ class Interpolate implements Expression {
|
|
|
246
199
|
}
|
|
247
200
|
|
|
248
201
|
serialize(): SerializedExpression {
|
|
249
|
-
let interpolation;
|
|
202
|
+
let interpolation: [InterpolationType['name'], ...number[]];
|
|
250
203
|
if (this.interpolation.name === 'linear') {
|
|
251
|
-
interpolation = [
|
|
204
|
+
interpolation = ['linear'];
|
|
252
205
|
} else if (this.interpolation.name === 'exponential') {
|
|
253
206
|
if (this.interpolation.base === 1) {
|
|
254
|
-
interpolation = [
|
|
207
|
+
interpolation = ['linear'];
|
|
255
208
|
} else {
|
|
256
|
-
interpolation = [
|
|
209
|
+
interpolation = ['exponential', this.interpolation.base];
|
|
257
210
|
}
|
|
258
211
|
} else {
|
|
259
|
-
|
|
260
|
-
interpolation = ["cubic-bezier" ].concat(this.interpolation.controlPoints);
|
|
212
|
+
interpolation = ['cubic-bezier', ...this.interpolation.controlPoints];
|
|
261
213
|
}
|
|
262
214
|
|
|
263
215
|
const serialized = [this.operator, interpolation, this.input.serialize()];
|
|
264
216
|
|
|
265
|
-
|
|
266
|
-
serialized.push(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
this.labels[i],
|
|
271
|
-
this.outputs[i].serialize()
|
|
272
|
-
);
|
|
273
|
-
}
|
|
217
|
+
for (let i = 0; i < this.labels.length; i++) {
|
|
218
|
+
serialized.push(
|
|
219
|
+
this.labels[i],
|
|
220
|
+
this.outputs[i].serialize()
|
|
221
|
+
);
|
|
274
222
|
}
|
|
275
223
|
return serialized;
|
|
276
224
|
}
|
|
@@ -25,9 +25,8 @@ class Let implements Expression {
|
|
|
25
25
|
fn(this.result);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Let | null |
|
|
28
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Let | null | void {
|
|
29
29
|
if (args.length < 4)
|
|
30
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Let'.
|
|
31
30
|
return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);
|
|
32
31
|
|
|
33
32
|
const bindings: Array<[string, Expression]> = [];
|
|
@@ -35,12 +34,10 @@ class Let implements Expression {
|
|
|
35
34
|
const name = args[i];
|
|
36
35
|
|
|
37
36
|
if (typeof name !== 'string') {
|
|
38
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Let'.
|
|
39
37
|
return context.error(`Expected string, but found ${typeof name} instead.`, i);
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
if (/[^a-zA-Z0-9_]/.test(name)) {
|
|
43
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Let'.
|
|
44
41
|
return context.error(`Variable names must contain only alphanumeric characters or '_'.`, i);
|
|
45
42
|
}
|
|
46
43
|
|
|
@@ -61,12 +58,10 @@ class Let implements Expression {
|
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
serialize(): SerializedExpression {
|
|
64
|
-
const serialized = ["let"];
|
|
61
|
+
const serialized: SerializedExpression[] = ["let"];
|
|
65
62
|
for (const [name, expr] of this.bindings) {
|
|
66
|
-
// @ts-expect-error - TS2345 - Argument of type 'SerializedExpression' is not assignable to parameter of type 'string'.
|
|
67
63
|
serialized.push(name, expr.serialize());
|
|
68
64
|
}
|
|
69
|
-
// @ts-expect-error - TS2345 - Argument of type 'SerializedExpression' is not assignable to parameter of type 'string'.
|
|
70
65
|
serialized.push(this.result.serialize());
|
|
71
66
|
return serialized;
|
|
72
67
|
}
|
|
@@ -58,8 +58,7 @@ class Literal implements Expression {
|
|
|
58
58
|
// Constant-folding can generate Literal expressions that you
|
|
59
59
|
// couldn't actually generate with a "literal" expression,
|
|
60
60
|
// so we have to implement an equivalent serialization here
|
|
61
|
-
|
|
62
|
-
return ["rgba"].concat(this.value.toRenderColor(null).toArray());
|
|
61
|
+
return ["rgba" as SerializedExpression].concat(this.value.toRenderColor(null).toArray());
|
|
63
62
|
} else if (this.value instanceof Formatted) {
|
|
64
63
|
// Same as Color
|
|
65
64
|
return this.value.serialize();
|
|
@@ -28,12 +28,10 @@ class Match implements Expression {
|
|
|
28
28
|
this.otherwise = otherwise;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Match | null |
|
|
31
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Match | null | void {
|
|
32
32
|
if (args.length < 5)
|
|
33
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
34
33
|
return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);
|
|
35
34
|
if (args.length % 2 !== 1)
|
|
36
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
37
35
|
return context.error(`Expected an even number of arguments.`);
|
|
38
36
|
|
|
39
37
|
let inputType;
|
|
@@ -52,23 +50,17 @@ class Match implements Expression {
|
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
const labelContext = context.concat(i);
|
|
55
|
-
|
|
56
|
-
if (labels.length === 0) {
|
|
57
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
53
|
+
if ((labels as unknown[]).length === 0) {
|
|
58
54
|
return labelContext.error('Expected at least one branch label.');
|
|
59
55
|
}
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
for (const label of labels) {
|
|
57
|
+
for (const label of (labels as unknown[])) {
|
|
63
58
|
if (typeof label !== 'number' && typeof label !== 'string') {
|
|
64
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
65
59
|
return labelContext.error(`Branch labels must be numbers or strings.`);
|
|
66
60
|
} else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {
|
|
67
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
68
61
|
return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);
|
|
69
62
|
|
|
70
63
|
} else if (typeof label === 'number' && Math.floor(label) !== label) {
|
|
71
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
72
64
|
return labelContext.error(`Numeric branch labels must be integer values.`);
|
|
73
65
|
|
|
74
66
|
} else if (!inputType) {
|
|
@@ -78,7 +70,6 @@ class Match implements Expression {
|
|
|
78
70
|
}
|
|
79
71
|
|
|
80
72
|
if (typeof cases[String(label)] !== 'undefined') {
|
|
81
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Match'.
|
|
82
73
|
return labelContext.error('Branch labels must be unique.');
|
|
83
74
|
}
|
|
84
75
|
|
|
@@ -26,14 +26,12 @@ class Step implements Expression {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Step | null |
|
|
29
|
+
static parse(args: ReadonlyArray<unknown>, context: ParsingContext): Step | null | void {
|
|
30
30
|
if (args.length - 1 < 4) {
|
|
31
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Step'.
|
|
32
31
|
return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
if ((args.length - 1) % 2 !== 0) {
|
|
36
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Step'.
|
|
37
35
|
return context.error(`Expected an even number of arguments.`);
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -55,12 +53,10 @@ class Step implements Expression {
|
|
|
55
53
|
const valueKey = i + 1;
|
|
56
54
|
|
|
57
55
|
if (typeof label !== 'number') {
|
|
58
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Step'.
|
|
59
56
|
return context.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);
|
|
60
57
|
}
|
|
61
58
|
|
|
62
59
|
if (stops.length && stops[stops.length - 1][0] >= label) {
|
|
63
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Step'.
|
|
64
60
|
return context.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.', labelKey);
|
|
65
61
|
}
|
|
66
62
|
|
|
@@ -88,10 +88,9 @@ class EvaluationContext {
|
|
|
88
88
|
return 0;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
parseColor(input: string): Color |
|
|
91
|
+
parseColor(input: string): Color | undefined {
|
|
92
92
|
let cached = this._parseColorCache[input];
|
|
93
93
|
if (!cached) {
|
|
94
|
-
// @ts-expect-error - TS2322 - Type 'void | Color' is not assignable to type 'Color'. | TS2322 - Type 'void | Color' is not assignable to type 'Color'.
|
|
95
94
|
cached = this._parseColorCache[input] = Color.parse(input);
|
|
96
95
|
}
|
|
97
96
|
return cached;
|
package/expression/index.ts
CHANGED
|
@@ -339,19 +339,16 @@ export interface CompositeExpression {
|
|
|
339
339
|
export type StylePropertyExpression = ConstantExpression | SourceExpression | CameraExpression | CompositeExpression;
|
|
340
340
|
|
|
341
341
|
export function createPropertyExpression(
|
|
342
|
-
expression:
|
|
342
|
+
expression: any,
|
|
343
343
|
propertySpec: StylePropertySpecification,
|
|
344
344
|
scope?: string | null,
|
|
345
345
|
options?: ConfigOptions | null,
|
|
346
346
|
): Result<StylePropertyExpression, Array<ParsingError>> {
|
|
347
347
|
expression = createExpression(expression, propertySpec, scope, options);
|
|
348
|
-
// @ts-expect-error - TS2339 - Property 'result' does not exist on type 'unknown'.
|
|
349
348
|
if (expression.result === 'error') {
|
|
350
|
-
// @ts-expect-error - TS2322 - Type 'unknown' is not assignable to type 'Result<StylePropertyExpression, ParsingError[]>'.
|
|
351
349
|
return expression;
|
|
352
350
|
}
|
|
353
351
|
|
|
354
|
-
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
355
352
|
const parsed = expression.value.expression;
|
|
356
353
|
|
|
357
354
|
const isFeatureConstant = isConstant.isFeatureConstant(parsed);
|
|
@@ -386,18 +383,14 @@ export function createPropertyExpression(
|
|
|
386
383
|
|
|
387
384
|
if (!zoomCurve) {
|
|
388
385
|
return success((isFeatureConstant && isLineProgressConstant) ?
|
|
389
|
-
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
390
386
|
(new ZoomConstantExpression('constant', expression.value, isLightConstant, isLineProgressConstant) as ConstantExpression) :
|
|
391
|
-
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
392
387
|
(new ZoomConstantExpression('source', expression.value, isLightConstant, isLineProgressConstant) as SourceExpression));
|
|
393
388
|
}
|
|
394
389
|
|
|
395
390
|
const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;
|
|
396
391
|
|
|
397
392
|
return success((isFeatureConstant && isLineProgressConstant) ?
|
|
398
|
-
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
399
393
|
(new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType, isLightConstant, isLineProgressConstant) as CameraExpression) :
|
|
400
|
-
// @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
|
|
401
394
|
(new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType, isLightConstant, isLineProgressConstant) as CompositeExpression));
|
|
402
395
|
}
|
|
403
396
|
|
|
@@ -70,7 +70,7 @@ class ParsingContext {
|
|
|
70
70
|
options: {
|
|
71
71
|
typeAnnotation?: 'assert' | 'coerce' | 'omit';
|
|
72
72
|
} = {},
|
|
73
|
-
): Expression | null |
|
|
73
|
+
): Expression | null | void {
|
|
74
74
|
if (index || expectedType) {
|
|
75
75
|
return this.concat(index, null, expectedType, bindings)._parse(expr, options);
|
|
76
76
|
}
|
|
@@ -94,7 +94,7 @@ class ParsingContext {
|
|
|
94
94
|
options: {
|
|
95
95
|
typeAnnotation?: 'assert' | 'coerce' | 'omit';
|
|
96
96
|
} = {},
|
|
97
|
-
): Expression | null |
|
|
97
|
+
): Expression | null | void {
|
|
98
98
|
return this.concat(index, key, expectedType, bindings)._parse(expr, options);
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -103,7 +103,7 @@ class ParsingContext {
|
|
|
103
103
|
options: {
|
|
104
104
|
typeAnnotation?: 'assert' | 'coerce' | 'omit';
|
|
105
105
|
},
|
|
106
|
-
): Expression | null |
|
|
106
|
+
): Expression | null | void {
|
|
107
107
|
if (expr === null || typeof expr === 'string' || typeof expr === 'boolean' || typeof expr === 'number') {
|
|
108
108
|
expr = ['literal', expr];
|
|
109
109
|
}
|
|
@@ -120,7 +120,6 @@ class ParsingContext {
|
|
|
120
120
|
|
|
121
121
|
if (Array.isArray(expr)) {
|
|
122
122
|
if (expr.length === 0) {
|
|
123
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
124
123
|
return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);
|
|
125
124
|
}
|
|
126
125
|
|
|
@@ -170,13 +169,10 @@ class ParsingContext {
|
|
|
170
169
|
// Try to parse as array
|
|
171
170
|
return Coercion.parse(['to-array', expr], this);
|
|
172
171
|
} else if (typeof expr === 'undefined') {
|
|
173
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
174
172
|
return this.error(`'undefined' value invalid. Use null instead.`);
|
|
175
173
|
} else if (typeof expr === 'object') {
|
|
176
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
177
174
|
return this.error(`Bare objects invalid. Use ["literal", {...}] instead.`);
|
|
178
175
|
} else {
|
|
179
|
-
// @ts-expect-error - TS2322 - Type 'void' is not assignable to type 'Expression'.
|
|
180
176
|
return this.error(`Expected an array, but found ${typeof expr} instead.`);
|
|
181
177
|
}
|
|
182
178
|
}
|
package/format.ts
CHANGED
package/function/index.ts
CHANGED
package/migrate/v8.ts
CHANGED
package/migrate/v9.ts
CHANGED
package/migrate.ts
CHANGED
package/package.json
CHANGED
package/read_style.ts
CHANGED