mapbox / mapbox/mapbox-gl-js

Perhaps ['match'...] shouldn't require 4 arguments

Open
#7,661 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

This wasn't valid as a match expression:

```
'fill-color': ['match', ['get','type'],
/*'park', 'lightgreen',
'wetland','darkgreen',
'school','pink',
'project','red',
'service','cyan',
'polder','hsla(200,70%,50%,0.3)',
'farm', 'hsl(60,90%,60%)',*/
// 'white'
colors.lightgreen
],
```

That is, a `match` where there is only the default value (everything else was temporarily commented out). It seems legitimate by analogy with:

```
switch(x) {
default: f()
}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the map expression parser validates the `match` expression shown in the issue, then look for existing tests covering `match` arguments. Confirm the desired behavior for an expression containing only a default value and add coverage showing whether that form is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.