Skip to content

Commit a35e63a

Browse files
committed
fix: make Expression not readonly to support web type
1 parent 66ef73b commit a35e63a

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/types.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
// - Autocomplete + typo detection on operator names inside this package.
1111
// - Cross-platform drift caught at the construction site: an operator not
1212
// in this union fails to compile here, before it can reach a consumer.
13-
// - Zero casts for the app-side consumer (types match `@rnmapbox/maps`).
14-
// - Zero casts for the web-side consumer: `mapbox-gl`'s
15-
// `ExpressionSpecification` is `[string, ...any[]]` (looser), so a value
16-
// typed as `readonly [ExpressionName, ...]` flows in without a cast.
13+
// - Zero casts for the app-side consumer: our mutable tuple is assignable
14+
// to `@rnmapbox/maps`'s `readonly [ExpressionName, ...]` variant.
15+
// - Zero casts for the web-side consumer: the shape matches `mapbox-gl`'s
16+
// `ExpressionSpecification` (`[string, ...any[]]`) directly. A `readonly`
17+
// tuple would NOT be assignable there — TS rejects `readonly` → mutable.
1718
//
1819
// Keep in sync with `@rnmapbox/maps` if their `ExpressionName` union grows.
1920

@@ -110,7 +111,7 @@ type ExpressionField =
110111
| ExpressionField[]
111112
| {[key: string]: ExpressionField};
112113

113-
export type Expression = readonly [ExpressionName, ...ExpressionField[]];
114+
export type Expression = [ExpressionName, ...ExpressionField[]];
114115
export type FilterExpression = Expression;
115116

116117
// Value of a text-field property — a string or expression that produces a string.

0 commit comments

Comments
 (0)